mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 10:41:56 -05:00
A custom `SourceMapSource` can optionally provide its own `skipTrivia` function. If this is not provided then the compiler will use the default function designed for TypeScript source files. Previously, when calling this default function we were passing the current `sourceMapSource` rather than the specified `source` whose trivia needs to be skipped. This resulted in the `pos` being incorrectly calculated for external source files that need mapping. **Side note:** There are actually two possible constructors available for creating `SourceMapSource` objects. One of them defaults to an identity function for the `skipTrivia` function if it is not provided (see49689894d7/src/compiler/utilities.ts (L6972-L6976)) and the other one leaves the `skipTrivia` field `undefined` (see5fc8f1dd80/src/services/services.ts (L776-L797)) Unfortunately, it appears that the second of these two constructors is the one available when importing the "typescript" module in node.js code.