npm / @babel/generator
@babel/generator
What changed in @babel/generator 8, from its official release notes, upgrade guides and advisories. Also covers @types/babel__generator. Sources checked 2026-10-27.
20 breaking1 deprecations2 new APIs and options3 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@babel/generator 826 changes
Breaking changes 20
The undocumented CodeGenerator class has been removed; use the default exported generate function instead.
The jsonCompatibleStrings option was removed; use jsescOption: { json: true } instead.
Importing internal files is disallowed; use the exported API only.
BigIntLiteral.value is a bigint rather than a string; JSON.stringify cannot serialize bigint values.
TSParenthesizedType is no longer generated unless createParenthesizedExpression is enabled; node.extra.parenthesized can indicate parentheses when it is false.
Dynamic import() is represented by an ImportExpression node instead of a CallExpression with an Import callee.
Generated string literals now output non-ASCII characters as-is; ensure JavaScript files are served as UTF-8, or restore the previous behavior with jsescOption: { minimal: false }.
The parameters field is renamed to params on TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSFunctionType, TSConstructorType, and TSMethodSignature.
The typeAnnotation field is renamed to returnType on TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSFunctionType, TSConstructorType, and TSMethodSignature.
The superTypeParameters field is renamed to superTypeArguments in ClassDeclaration and ClassExpression.
Class implements entries use TSClassImplements instead of TSExpressionWithTypeArguments; the node uses typeArguments, and qualified expressions are MemberExpression nodes.
TSEnumDeclaration members are now wrapped within a TSEnumBody node.
Exported TSImportEqualsDeclaration is parsed inside an ExportNamedDeclaration, and its isExport field is removed.
TSImportType.argument is renamed to source.
Interface heritage entries use TSInterfaceHeritage instead of TSExpressionWithTypeArguments; the node uses typeArguments, and qualified expressions are MemberExpression nodes.
TSMappedType flattens typeParameter into key and constraint properties on the node itself.
A dotted namespace name such as X.Y is represented as one TSModuleDeclaration whose name is a TSQualifiedName, rather than nested TSModuleDeclaration nodes.
Interpolated template literal types are represented by TSTemplateLiteralType; non-interpolated template literal types retain their existing AST shape.
TSTypeParameter.name is an Identifier node rather than a plain string.
The typeParameters field is renamed to typeArguments on CallExpression, JSXOpeningElement, NewExpression, OptionalCallExpression, TSImportType, TSInstantiationExpression, TSTypeQuery, and TSTypeReference.
Deprecations 1
The legacy import() AST can be requested with createImportExpressions: false, but is deprecated and the parser option will be removed in Babel 9.
New APIs and options 2
When both estree and typescript parser plugins are enabled, Babel creates TSAbstractMethodDefinition nodes.
When both estree and typescript parser plugins are enabled, Babel creates TSPropertyDefinition nodes.
Fixes and other changes 3
Keeps parentheses around optional chaining in tagged expressions.
Improves the check for parentheses around new callees during code generation.
TSTypeQuery.exprName can be a ThisExpression rather than an Identifier for typeof this.