dominikg / tsconfck

A utility to find and parse tsconfig files without depending on typescript
Other
293 stars 14 forks source link

fix(parse): normalize parsing of compileOnSave to match native #101

Closed duanwilliam closed 1 year ago

duanwilliam commented 1 year ago

When compileOnSave is set to false in the tsconfig, ts.parseJsonConfigFileContent omits the option from the result, e.g.

{
  "compileOnSave": false,
  // ...
}

becomes

{
  // ...
}

It's a draft PR for now since it hasn't added any tests. I noticed that toJson and parse seem to share expected results for the most part so I wasn't sure the best way to add tests for just parse.

dominikg commented 1 year ago

Hey, sorry for not getting to this earlier. The tests are a bit messy today, plan is to convert them to vitest and use separate snapshots to avoid this kind of reuse in expected data.

A new fixture in tests/parse/valid/compileOnSave/tsconfig.json should work though.

However, there is special handling for compileOnSave in parse-native here: https://github.com/dominikg/tsconfck/blob/a8efea2215aa2702d8a03cb0117936ba44959ad4/src/parse-native.ts#L236

Did the default behavior of ts.parseJsonConfigFileContent change?

Also may I ask why this change important for you? Keeping "compileOnSave":false in the parse output is closer to the original file content and doesn't lead to a change in behavior to my knowledge.

dominikg commented 1 year ago

i'll close this one, the question above went unanswered and now version-3 has been merged into main, so it would be easier to start over if this is still of interest.