-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
i: needs triageoutdatedA 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 issue
Description
💻
- Would you like to work on a fix?
How are you using Babel?
@babel/cli
Input code
const parser = require('@babel/parser');
const generator = require('@babel/generator').default;
const sourceCode = 'const func = ({ str }: {str?:string} = {}) => str;';
console.log(`sourceCode is ${JSON.stringify(sourceCode)}`);
const sourceAST = parser.parse(sourceCode, {
sourceType: 'module',
plugins: [
'jsx',
'typescript',
],
});
const genCode = generator(sourceAST, {
compact: false,
concise: false,
retainLines: true,
retainFunctionParens: true,
plugins: [
'jsx',
'typescript',
],
}).code;
console.log(`genCode is ${JSON.stringify(genCode)}`);Configuration file name
babel.config.json
Configuration
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"edge": "17",
"firefox": "60",
"chrome": "67",
"safari": "11.1"
},
"useBuiltIns": "usage",
"corejs": "3.6.5"
}
]
]
}
Current and expected behavior
@babel/generator keep function params typeAnnotation
Environment
"@babel/generator": "^7.25.5",
"@babel/parser": "^7.25.4",
"node": "16.19.0"
Possible solution
No response
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
i: needs triageoutdatedA 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 issue