I"m trying to pass a generic value to a type accessed through an index, but I'm running into a syntax error.
I've got a function type signature named onCreateNode defined on an interface named GatsbyNode:
interface GatsbyNode {
...
onCreateNode?<TNode extends object = {}>(
args: CreateNodeArgs<TNode>,
options?: PluginOptions,
callback?: PluginCallback
): void
...
I've now created a function that is also named onCreateNode and I want to assign it the type of GatsbyNode['onCreateNode'] while passing a value to the TNode generic:
export const onCreateNode: GatsbyNode['onCreateNode']<AGenericTypeIWantToPassIn> = ...
However, I get a syntax error at the first angle bracket (<) telling me that this is not valid TypeScript.