-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v2] typescript component with StaticQuery + interface declaration doesn't work unless semicolons are inserted #6163
Comments
This is mysterious behaviour indeed. The existence of a |
Yep, it's definitely a problem with that. I actually tried to reproduce it with only |
It seems to be happening when Gatsby is parsing the GraphQL queries, but I have a limited understanding how/when that actually happens. Could someone point to an explanation? |
Ok I think I have this figured out. When Gatsby is parsing the queries, it's using This is quite subtle though, since if the file doesn't include the string "graphql" the parsing is skipped. This is the reason why I didn't run to this problem earlier myself. Anyway, this really means that typescript parsing is quite broken atm. For example the issue #6157 is clearly related to this. |
Description
As mentioned on #5789, any component that has both a
StaticQuery
and a TSinterface
(ortype
) declaration will flat out fail to compile the GraphQL fragments/queries.Inserting semicolons inside the
interface
/type
declaration seems to be the "solution" at the moment... but it's a hacky workaround at best, and I'm not sure that breaking a linting rule is a true solution to this problem.Other than that, this error log appears:
I've also discovered this while testing out my
typescript-plus
starter with v2 of Gatsby. I'm in the early stages of converting it, and honestly it's not a big deal of an issue, but still a weirdness that threw me off regardless...Steps to reproduce
next
branch ofgatsby-starter-typescript-plus
../layouts/index.tsx
component.StaticQueryProps
type.Expected result
GraphQL fragments/queries should be processed, regardless of whether or not the
interface
/type
has a semicolon.Actual result
GraphQL fragments/queries aren't processed when semicolons don't exist, and page shows up the Loading message.
Environment
File contents (if changed)
gatsby-config.js
: See repo.package.json
: See repo.gatsby-node.js
: See repo.gatsby-browser.js
: See repo.gatsby-ssr.js
: See repo.The text was updated successfully, but these errors were encountered: