-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Labels
Description
Motivation
JSDoc type comments or casting (eg. /** @type {string} */(value)
)
import * as acorn from 'acorn';
import * as astring from 'astring';
const code = `\
class A {
name;
}
`;
const ast = acorn.parse(code, { ecmaVersion: 2022 });
ast.body[0].body.body[0].comments = [{ type: 'Block', value: '* @type {string} ' }];
const formattedCode = astring.generate(ast, { comments: true })
console.log(formattedCode);
Expected behavior
class A {
/** @type {string} */
name;
}
Actual behavior
class A {
/** @type {string}*/
name;
}