-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
area: typescripti: regressionoutdatedA 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: generator
Description
💻
- Would you like to work on a fix?
How are you using Babel?
Programmatic API (babel.transform, babel.parse)
Input code
import { parseAsync } from "@babel/core";
import generator from "@babel/generator";
const ast = await parseAsync(
"(key as any) = value",
{
filename: "main.ts",
presets: [
[
"@babel/preset-typescript",
{ isTSX: false, allExtensions: true },
],
],
}
);
if (!ast) {
throw new Error("no ast");
}
const out = generator.default(ast, { sourceMaps: false }).code;
console.log(out);Configuration file name
No response
Configuration
none
Current and expected behavior
Expected output: (key as any) = value
Actual output: key as any = value.
Note that the actual output is invalid TypeScript
Environment
"@babel/core": "7.24.9",
"@babel/generator": "7.24.10",
"@babel/preset-typescript": "7.24.7"
Possible solution
No response
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: typescripti: regressionoutdatedA 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: generator
