-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
console.log(t.TSTypeOperator(t.TSTypeQuery(t.Identifier('x')), 'keyof'));
Configuration file name
No response
Configuration
No response
Current and expected behavior
Current behaviour: operator field is null
Expected behaviour: operator field is keyof
I want to create node like this:
type ODirection = typeof ODirection[keyof typeof ODirection];But have only:
type ODirection = typeof ODirection[null typeof ODirection];When using:
const id = Identifier('ODirection');
const type = TSTypeAliasDeclaration(id, null, TSIndexedAccessType(TSTypeQuery(id), TSTypeOperator(TSTypeQuery(id), 'keyof')))Environment
latest babel
Possible solution
Add handling of operator to TSTypeQuery.
Looks like the problem in https://github.com/babel/babel/blob/main/packages/babel-types/src/builders/generated/index.ts#L2254:

It should be https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/ast-spec/src/type/TSTypeOperator/spec.ts:

Additional context
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