You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am trying to create a set of TSX code with babel and babel-types. When I get to my variableDeclarator -I need to add a type to it. in this case React.FC<{}>, I am to pass my variableDeclarator an Identifier. Which would typically just be a string name of the variable.. However, since I'm using typescript -I can see in AST-Explorer that the React.FC<{}> I want to add is technically on the variableDeclarators first argument, the Identifier.
In AST Tools, the Identifier has a property TypeAnnotation. But my editor insists Identifier only takes 1 arg, a name/string.
So I dug into it's types, node_modules/@babel/types/lib/index.d.ts, and I found that it indeed should maybe take more args?
Hey @Seanmclem! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."
The AST builder functions only take the most common AST properties as parameters. Specifically, all the builders for JavaScript nodes don't accept any Flow or TS property as parameter.
Hi, I am trying to create a set of TSX code with babel and babel-types. When I get to my variableDeclarator -I need to add a type to it. in this case
React.FC<{}>
, I am to pass my variableDeclarator an Identifier. Which would typically just be a string name of the variable.. However, since I'm using typescript -I can see in AST-Explorer that theReact.FC<{}>
I want to add is technically on the variableDeclarators first argument, the Identifier.In AST Tools, the Identifier has a property
TypeAnnotation
. But my editor insists Identifier only takes 1 arg, a name/string.So I dug into it's types,
node_modules/@babel/types/lib/index.d.ts
, and I found that it indeed should maybe take more args?It looks like it should maybe take up to 4.. However, elsewhere in the types file, I do see what my editor sees -which is
So I tried updating that line with the missing args, and that solved VSCode's intellisense complaints.. Ended up with something like this..
but when I run the code I still get an error -
Identifier: Too many arguments passed. Received 4 but can receive no more than 1
Is there something off with the compiler? Or am I missing something that would resolve all this?
Config
Expected Result
babel [types] should have a way to pass a typeAnnotation to an Identifier, or a working alternative
The text was updated successfully, but these errors were encountered: