microsoft / microsoft/TypeScript
Source Map includes mapping for line ending characters
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: Version 3.8.0-dev.20191023
Search Terms:
source map, source map new line
Code
tsc --inlineSourceMap test.ts
test.ts
console.log('hello');
console.log('world');
test.js
console.log('hello');
console.log('world');
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQztBQUNyQixPQUFPLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFDIn0=
Source map breaks down into:
"console": test.ts:1:0
".": test.ts:1:7
"log": test.ts:1:8
"(": test.ts:1:11
"'hello'": test.ts:1:12
")": test.ts:1:19
";": test.ts:1:20
"\n": test.ts:1:21 <-- line end
"console": test.ts:2:0
".": test.ts:2:7
"log": test.ts:2:8
"(": test.ts:2:11
"'world'": test.ts:2:12
")": test.ts:2:19
";": test.ts:2:20
"": test.ts:2:21 <-- line end
Expected behavior:
Line end characters left unmapped.
Actual behavior:
Line end characters are included in the mapping, with the column number that equals to the length of the line -- which exceeds the boundary, given that column number is 0-based in a source map.
The spec doesn't cover if mappings for line ending characters should be included. But this behavior breaks some tools (eg. source-map-explorer) with strict boundary checks.
Playground Link:
Related Issues:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with tsc --inlineSourceMap test.ts using the provided test.ts and inspect the inline source map in test.js. Trace how the compiler records mappings at line endings, then verify that the generated mappings no longer include those characters while the other mappings remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100