Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ts] Add support for template interpolations in types (#12131)
Co-authored-by: Brian Ng <bng412@gmail.com>
- Loading branch information
1 parent
9f40d6f
commit 3fd963f
Showing
10 changed files
with
106 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/typescript/types/literal-string-3/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let x: `foo-${bar + baz}`; |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/typescript/types/literal-string-3/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "Unexpected token, expected \"}\" (1:18)" | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/typescript/types/literal-string-4/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let x: `foo-${infer bar}`; |
73 changes: 73 additions & 0 deletions
73
packages/babel-parser/test/fixtures/typescript/types/literal-string-4/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":4,"end":25,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":25}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":4,"end":25,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":25},"identifierName":"x"}, | ||
"name": "x", | ||
"typeAnnotation": { | ||
"type": "TSTypeAnnotation", | ||
"start":5,"end":25,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":25}}, | ||
"typeAnnotation": { | ||
"type": "TSLiteralType", | ||
"start":7,"end":25,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":25}}, | ||
"literal": { | ||
"type": "TemplateLiteral", | ||
"start":7,"end":25,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":25}}, | ||
"expressions": [ | ||
{ | ||
"type": "TSInferType", | ||
"start":14,"end":23,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":23}}, | ||
"typeParameter": { | ||
"type": "TSTypeParameter", | ||
"start":20,"end":23,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":23}}, | ||
"name": "bar" | ||
} | ||
} | ||
], | ||
"quasis": [ | ||
{ | ||
"type": "TemplateElement", | ||
"start":8,"end":12,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":12}}, | ||
"value": { | ||
"raw": "foo-", | ||
"cooked": "foo-" | ||
}, | ||
"tail": false | ||
}, | ||
{ | ||
"type": "TemplateElement", | ||
"start":24,"end":24,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":24}}, | ||
"value": { | ||
"raw": "", | ||
"cooked": "" | ||
}, | ||
"tail": true | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"init": null | ||
} | ||
], | ||
"kind": "let" | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters