microsoft / microsoft/TypeScript

Source Map includes mapping for line ending characters

Aperta
#34,695 1 commento 4 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Domain: Source Maps
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

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:

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci il problema con tsc --inlineSourceMap test.ts usando il test.ts fornito e ispeziona la source map inline in test.js. Traccia il modo in cui il compilatore registra le mappature alla fine delle righe, quindi verifica che le mappature generate non includano più quei caratteri, mentre le altre mappature rimangano invariate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
compilers
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.