-
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
chore(babel-plugin-remove-graphql-queries): Convert index.js #23954
chore(babel-plugin-remove-graphql-queries): Convert index.js #23954
Conversation
…emove-graphql-queries/src/index
…emove-graphql-queries/src/index
return { | ||
visitor: { | ||
Program(path, state) { | ||
Program(path: NodePath<Program>, state: any): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we type state
to avoid any
? AFAIK we don't pass any options so generic one should work (if there is one)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's hard to tell what state
is supposed to be because there aren't many resources that I've found on writing babel plugins. Based on this type file, state
is either the generic type S
or any
, and after some digging it looks like S
is set to {}
by default. Are you thinking we should just create our own type for state
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update on this. I created a custom type for state
called IState
and I get an error:
Type '(this: {}, path: NodePath<Program>, state: IState) => void' is not assignable to type 'VisitNodeFunction<{}, Program> | VisitNodeObject<{}, Program> | undefined'.
Type '(this: {}, path: NodePath<Program>, state: IState) => void' is not assignable to type 'VisitNodeFunction<{}, Program>'.
Types of parameters 'state' and 'state' are incompatible.
Property 'file' is missing in type '{}' but required in type 'IState'.
I think it's because the type of state is expected to be {}
. However, when I explicitly declare the type like this:
Program(path: NodePath<Program>, state: {}): void {
...
}
I get an error saying property 'file' does not exist on type '{}'
. I'm unsure how to resolve this issue at the moment. If you know a solution, @pieh, feel free to just add it in.
Ok well the reported errors seem legit errors. So please run |
@zachtylr21 friendly ping. Do you want to keep working on this? I think it was close to being merged? |
@pvdz Yes I'd like to finish this and get it merged. Apologies, I didn't see your comment from 6 days ago. Is running |
I usually do |
…emove-graphql-queries/src/index
@pvdz I'm getting an error that says |
@pvdz There are also a bunch of linting errors in the |
The gatsby-admin stuff is either brand new or old problems that require a rebase/merge of master to resolve. I'll try that. |
…emove-graphql-queries/src/index
I'm a little confused at how to alter the It seems I need to alter the file Also, I'm not getting the errors on lines 249, 300, and 360. |
Co-authored-by: Vladimir Razuvaev <vladimir.razuvaev@gmail.com>
You guys will have to excuse my ignorance on a couple of these things, I'm pretty new to contributing to Gatsby. After changing I thought this meant I have to do I'm super confused as to why none of these packages can be found. Is there something I'm missing here? I really want to get this PR moving along but I keep running into frustrating issues like this. |
I pulled your branch, ran
CI fails with exact same error. So my best guess is that your dependency setup is messed up. Are you using npm? This may be the issue. If so I suggest you remove |
Ah, I was using |
…emove-graphql-queries/src/index
It seems something snapshotty is failing over this thing fc97669#diff-0cee23a635d1c08646f35342b6dee83f |
…emove-graphql-queries/src/index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm and tests are passing. Thank you 💜
…s#23954) * Declare Error class variables * Apply linter * Assert non-null NODE_ENV; remove unused state parameter * Fix eslint warning about non-null assertion * Declare return types on some functions * Prefix GraphQLTag interface with I * Declare function return types * Change getTagImport return type to any * Add babel types to dev dependencies * Add types in all functions before default export * Add types in all functions before default export * Type function parameters * Type jsx nodes * Type jsx nodes * Create visitor interfaces * Move 'as NodePath' * Use type instead of interface * Use type * Create custom State type * Create custom State type * Allow undefined members in StringInterpolationNotAllowedError * Wrap if statement in block Co-authored-by: Peter van der Zee <209817+pvdz@users.noreply.github.com> * chore: format * Change the way graphql is imported Co-authored-by: Vladimir Razuvaev <vladimir.razuvaev@gmail.com> * Fix typecheck errors * chore: format Co-authored-by: Peter van der Zee <209817+pvdz@users.noreply.github.com> Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com> Co-authored-by: Vladimir Razuvaev <vladimir.razuvaev@gmail.com>
Description
Convert
packages/babel-plugin-remove-graphql-queries/src/index.js
to TypeScriptRelated Issues
Related to #21995