TypeScript Compiler API wrapper for static analysis and programmatic code changes.
<!-- If you are contributing this bug fix then please read the instructions in CONTRIBUTING.md --> **Describe the bug** Version: 25.0.0 It's a very specific scenario, but I'm reporting just in case there's something underlying that's more concerning. If you enable useTrailingCommas, adding a method to an object literal with a template string of the form `${p}/*` will add an extra comma to the template string `${p},/*`. I might have time to try to dig deeper but figured I'd report it in case anything obvious sprung to mind for the root cause. (since it seems oddly specific for repro) **To Reproduce** ```ts import { Node, Project, SyntaxKind } from 'ts-morph'; const project = new Project({ manipulationSettings: { useTrailingCommas: true, }, }); const sourceFile = project.createSourceFile('example.ts', 'func({});'); const callExpressions = sourceFile.getDescendantsOfKind( SyntaxKind.CallExpression, ); const objectLiteral = callExpressions[0].getArguments()[0]; if (!Node.isObjectLiteralExpression(objectLiteral)) { throw new Error('Object literal expected'); } objectLiteral.addMethod({ name: 'logTemplate', statements: ['`${p}/*`;'], parameters: [{ name: 'p', type: 'string' }], }); console.info(sourceFile.getFullText()); ``` **Expected behavior** ``` func({ logTemplate(p: string) { `${p}/*`; } }); ``` **Actual behavior** ``` func({ logTemplate(p: string) { `${p},/*`; } }); ```
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be still under discussion. The issue was opened by kingston and has received 0 comments.