TypeStat
TypeStat copied to clipboard
SNC ! off by one character in BOM-encoded file
🐛 Bug Report TypeStat version: 0.5.2 TypeScript version: 4.4.4 Node version: 16.x
Seems files with BOM encoding mess up the character position for SNC. Perhaps this is an "issue" (using the term loosely) with Typescript's character position reporting @DanielRosenwasser?
Reproduction https://github.com/markjm/demos-by-commit/tree/typestat-demo-3
Easy fix (and the one I will be using) is to just stop using BOM-encoded files :), but submitting the bug for posterity
Thanks for the report @markjm! Yes, I suspect this is an issue with TypeScript's character position reporting. The createNonNullAssertion function inside TypeStat places the "!" at a position equal to node.end. In with_bom.ts that's 75.
On Windows after creating a new without_bom.ts file identical to with_bom.ts but in non-BOM UTF-8, the position is still 75.
Closing off as an old external issue. Please let me know if there's anything TypeStat should do!