💻
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
https://astexplorer.net/#/gist/5441a8fd17a10000071fc31cab269d1f/4d5a67647e7a8c7e6296e253b20c3b6c3105cd50
💻
How are you using Babel?
Programmatic API (
babel.transform,babel.parse)Input code
Configuration file name
No response
Configuration
No response
Current and expected behavior
Current behaviour:
operatorfield isnullExpected behaviour:
operatorfield iskeyofI want to create node like this:
But have only:
When using:
Environment
latest babel
Possible solution
Add handling of
operatortoTSTypeQuery.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
https://astexplorer.net/#/gist/5441a8fd17a10000071fc31cab269d1f/4d5a67647e7a8c7e6296e253b20c3b6c3105cd50