-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Closed
Copy link
Labels
area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: types
Description
💻
- Would you like to work on a fix?
How are you using Babel?
Programmatic API (babel.transform, babel.parse)
Input code
TaggedTemplateExpression
code_raw_str:
var code = "styledComponent<MyProps>`" +"font-size: 1.5${unit};`"
console.log(code)
styledComponent<MyProps>`font-size: 1.5${unit};`
ast-json-abbr
var t = parse(code);
t = t.body[0].expression;
{
"type": "TaggedTemplateExpression",
"tag": {
"type": "Identifier",
"name": "styledComponent"
},
"quasi": {/*...*/},
"typeParameters": { //--------------------------->the value of prop<typeParameters> is a Node
"type": "TSTypeParameterInstantiation",
"params": [
{
"type": "TSTypeReference",
"typeName": {
"type": "Identifier",
"name": "MyProps"
}
}
]
}
}
the-visitors-in-VISITOR_KEYS-only-list tag and quasi
const babel_typ = require("@babel/types")
> babel_typ.VISITOR_KEYS.TaggedTemplateExpression
[ 'tag', 'quasi' ]
>
///@babel/types/lib/definitions/core.js
(0, _utils.default)("TaggedTemplateExpression", {
visitor: ["tag", "quasi"],
aliases: ["Expression"],
fields: {
tag: {
validate: (0, _utils.assertNodeType)("Expression")
},
quasi: {
validate: (0, _utils.assertNodeType)("TemplateLiteral")
},
typeParameters: {//====>should this be a visitor-name?
//since its a Node (validated by assertNodeType)
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
optional: true
}
}
});
Configuration file name
No response
Configuration
No response
Current and expected behavior
should the typeParameters be in the visitor-names? or should NOT?
Environment
......
Binaries:
Node: 15.8.0 - /usr/local/bin/node
npm: 7.5.1 - /usr/local/bin/npm
......
{
.....
"name": "@babel/types",
"version": "7.14.5",
.....
}
Possible solution
No response
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: types