💻
How are you using Babel?
Programmatic API (babel.transform, babel.parse)
Input code
import * as t from "@babel/types";
import generate from "@babel/generator";
const param = t.tsTypeParameter(null, null, "T");
param.const = true; // HERE
const fn = t.arrowFunctionExpression([], t.blockStatement([]));
fn.typeParameters = t.tsTypeParameterDeclaration([
param,
])
const p = t.file(t.program([
t.variableDeclaration("const", [
t.variableDeclarator(t.identifier("x"), fn)
])
]));
console.log(generate(p).code);
Configuration file name
No response
Configuration
Current and expected behavior
Current:
Expected:
const x = <const T,>() => {};
Environment
@babel/generator: 7.26.5
OS: Linux 6.8
Node: 22.11.0 - node
Yarn: 1.22.22 - yarn
npm: 10.9.0 - npm
Possible solution
No response
Additional context
No response
💻
How are you using Babel?
Programmatic API (
babel.transform,babel.parse)Input code
Configuration file name
No response
Configuration
Current and expected behavior
Current:
Expected:
Environment
@babel/generator: 7.26.5
OS: Linux 6.8
Node: 22.11.0 - node
Yarn: 1.22.22 - yarn
npm: 10.9.0 - npm
Possible solution
No response
Additional context
No response