dsherret / ts-morph

TypeScript Compiler API wrapper for static analysis and programmatic code changes.
https://ts-morph.com
MIT License
4.9k stars 194 forks source link

Differences when running on code with semicolons vs without semicolons #1536

Open niklas-wortmann opened 4 months ago

niklas-wortmann commented 4 months ago

Describe the bug

Version: 22.0.0

I am doing code transformation with ts morph. Running sourceFile.insertVariableStatement(startLineNumber, {...} on code that uses semicolons returns vastly different results than running it on code without semicolons.

To Reproduce

The latest commit of this repository contains a failing test due to this issue. https://github.com/niklas-wortmann/nuxt/blob/useAsyncDataMigration/packages/nuxt/schematics/migrations/4_0_0/index.ts

running npm run test on this package json https://github.com/niklas-wortmann/nuxt/blob/useAsyncDataMigration/packages/nuxt/schematics/package.json will show the failing tests due to missing semicolons on the source file

Expected behavior

Semicolons shouldn't have an impact here :D