Gatsby: Major type issue in v2.3.35

Created on 2 May 2019  路  6Comments  路  Source: gatsbyjs/gatsby

This issue is about the TypeScript types shipped by Gatsby.

Description

As shown here, a commit was made that made it into v2.3.35 that changed the GatsbyNode type's name to just Node. Although this was a breaking change for those depending on the types, I thought it would be a simple thing to update and get our codebase compiling again.

However, I was getting a strange error message when I updated the type (GatsbyNode) to the new name (Node):

Type '{ createPages: ((args: CreatePagesArgs & { traceId: "initial-createPages"; }, options?: PluginOptions | undefined, callback?: PluginCallback | undefined) => void) | undefined; }' is missing the following properties from type 'Node': id, parent, children, internal. ts(2739)

After looking further into the issue, I realised that Gatsby already exports a separate type called Node (that is related to this kind of node), which can be seen here. This is what was causing the above error message, as this Node type requires the id, parent, children and internal properties to be defined.

The likely reason this mistake was allowed to slip through is because of Declaration Merging in TypeScript.

To fix this issue, please revert this name change made to this type (Node -> GatsbyNode).

confirmed bug

All 6 comments

Tagging @wKovacs64 and @pieh as they were the ones that created and committed this change.

Yes, you are totally right, I'm not sure how I didn't spot it, I'll push fix shortly

@joealden can you take a look at https://github.com/gatsbyjs/gatsby/pull/13799 and let me know if this is what you meant?

@pieh yeah that is what I meant, looks good!

Wow, yeah that definitely should not have made it in. Can't believe we all missed it! :sweat_smile: Thanks for the quick fix, @pieh.

Published [email protected]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dustinhorton picture dustinhorton  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments

theduke picture theduke  路  3Comments

ghost picture ghost  路  3Comments

andykais picture andykais  路  3Comments