-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
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 issue
Description
💻
- Would you like to work on a fix?
How are you using Babel?
Programmatic API (babel.transform, babel.parse)
Input code
type Bar = { [key in Foo] };Configuration file name
No response
Configuration
options passed to @babel/parser:
{
sourceType: 'module',
plugins: ['typescript'],
}Current and expected behavior
When just parsed using @babel/parser and generated back using @babel/generator, with nothing else being done to AST, the mentioned code becomes:
type Bar = { [key in Foo]: };which is an ivalid typescript, raises "Type expected" error because indeed, there is no type after :.
Expected behavior:
It should be generated back into
type Bar = { [key in Foo] };Environment
- Babel: 7.24.3
- @babel/plugin-syntax-typescript: 7.24.1
- Node: 18.19.0
- npm: 10.2.3
Possible solution
If the MappedType node has its type field set to undefined, there should be no : printed out after the [key in Foo].
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 issue