From 5124913eee9616b8c55a7b720bc494f5d94bd1c5 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 23 Feb 2026 09:52:26 -0800 Subject: [PATCH 1/9] Starting --- internal/core/core.go | 14 ++ internal/diagnosticwriter/diagnosticwriter.go | 4 +- internal/format/indent.go | 12 +- internal/format/span.go | 8 +- internal/printer/textwriter.go | 6 +- internal/printer/utilities.go | 16 +- internal/scanner/scanner.go | 89 ++++++++- .../harnessutil/sourcemap_recorder.go | 10 +- ...clarationEmitLateBoundAssignments2.symbols | 8 +- ...tionEmitLateBoundAssignments2.symbols.diff | 8 +- .../extendedUnicodePlaneIdentifiers.symbols | 4 +- ...tendedUnicodePlaneIdentifiers.symbols.diff | 10 +- ...tendedUnicodePlaneIdentifiersJSDoc.symbols | 4 +- ...dUnicodePlaneIdentifiersJSDoc.symbols.diff | 17 -- ...sourceMap-LineBreaks(target=es2015).js.map | 4 +- ...eMap-LineBreaks(target=es2015).js.map.diff | 8 - ...ap-LineBreaks(target=es2015).sourcemap.txt | 26 +-- ...neBreaks(target=es2015).sourcemap.txt.diff | 58 +----- ...EscapesInNames02(target=es2015).errors.txt | 8 +- ...esInNames02(target=es2015).errors.txt.diff | 12 -- ...codeEscapesInNames02(target=es2015).js.map | 4 +- ...scapesInNames02(target=es2015).js.map.diff | 4 +- ...apesInNames02(target=es2015).sourcemap.txt | 134 ++++++------- ...nNames02(target=es2015).sourcemap.txt.diff | 179 +++--------------- ...odeEscapesInNames02(target=es2015).symbols | 4 +- ...capesInNames02(target=es2015).symbols.diff | 10 - 26 files changed, 272 insertions(+), 389 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).js.map.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).symbols.diff diff --git a/internal/core/core.go b/internal/core/core.go index aa553ee396..2fe7bcffaf 100644 --- a/internal/core/core.go +++ b/internal/core/core.go @@ -9,6 +9,7 @@ import ( "strings" "sync" "unicode" + "unicode/utf16" "unicode/utf8" "github.com/microsoft/typescript-go/internal/debug" @@ -440,6 +441,9 @@ func ComputeECMALineStartsSeq(text string) iter.Seq[TextPos] { } } +// PositionToLineAndCharacter returns the 0-based line and byte offset from the +// start of that line for the given byte position, using the provided line starts. +// The character is a raw UTF-8 byte offset from the line start, not a UTF-16 code unit count. func PositionToLineAndCharacter(position int, lineStarts []TextPos) (line int, character int) { line = max(sort.Search(len(lineStarts), func(i int) bool { return int(lineStarts[i]) > position @@ -447,6 +451,16 @@ func PositionToLineAndCharacter(position int, lineStarts []TextPos) (line int, c return line, position - int(lineStarts[line]) } +// UTF16Len returns the number of UTF-16 code units needed to +// represent the given UTF-8 encoded string. +func UTF16Len(s string) int { + n := 0 + for _, r := range s { + n += utf16.RuneLen(r) + } + return n +} + func Flatten[T any](array [][]T) []T { var result []T for _, subArray := range array { diff --git a/internal/diagnosticwriter/diagnosticwriter.go b/internal/diagnosticwriter/diagnosticwriter.go index 2ac8c2e268..66c4d78756 100644 --- a/internal/diagnosticwriter/diagnosticwriter.go +++ b/internal/diagnosticwriter/diagnosticwriter.go @@ -196,10 +196,10 @@ func writeCodeSnippet(writer io.Writer, sourceFile FileLike, start int, length i i = lastLine - 1 } - lineStart := scanner.GetECMAPositionOfLineAndCharacter(sourceFile, i, 0) + lineStart := scanner.GetECMAPositionOfLineAndByteOffset(sourceFile, i, 0) var lineEnd int if i < lastLineOfFile { - lineEnd = scanner.GetECMAPositionOfLineAndCharacter(sourceFile, i+1, 0) + lineEnd = scanner.GetECMAPositionOfLineAndByteOffset(sourceFile, i+1, 0) } else { lineEnd = len(sourceFile.Text()) } diff --git a/internal/format/indent.go b/internal/format/indent.go index 2ac6c4d8b0..4d074e8b0b 100644 --- a/internal/format/indent.go +++ b/internal/format/indent.go @@ -14,7 +14,7 @@ import ( ) func GetIndentationForNode(n *ast.Node, ignoreActualIndentationRange *core.TextRange, sourceFile *ast.SourceFile, options *lsutil.FormatCodeSettings) int { - startline, startpos := scanner.GetECMALineAndCharacterOfPosition(sourceFile, scanner.GetTokenPosOfNode(n, sourceFile, false)) + startline, startpos := scanner.GetECMALineAndByteOffsetOfPosition(sourceFile, scanner.GetTokenPosOfNode(n, sourceFile, false)) return getIndentationForNodeWorker(n, startline, startpos, ignoreActualIndentationRange /*indentationDelta*/, 0, sourceFile /*isNextChild*/, false, options) } @@ -104,7 +104,7 @@ func getIndentationForNodeWorker( parent = current.Parent if useTrueStart { - currentStartLine, currentStartCharacter = scanner.GetECMALineAndCharacterOfPosition(sourceFile, scanner.GetTokenPosOfNode(current, sourceFile, false)) + currentStartLine, currentStartCharacter = scanner.GetECMALineAndByteOffsetOfPosition(sourceFile, scanner.GetTokenPosOfNode(current, sourceFile, false)) } else { currentStartLine = containingListOrParentStartLine currentStartCharacter = containingListOrParentStartCharacter @@ -170,7 +170,7 @@ func getActualIndentationForListStartLine(list *ast.NodeList, sourceFile *ast.So if list == nil { return -1 } - line, char := scanner.GetECMALineAndCharacterOfPosition(sourceFile, list.Loc.Pos()) + line, char := scanner.GetECMALineAndByteOffsetOfPosition(sourceFile, list.Loc.Pos()) return findColumnForFirstNonWhitespaceCharacterInLine(line, char, sourceFile, options) } @@ -200,7 +200,7 @@ func deriveActualIndentationFromList(list *ast.NodeList, index int, sourceFile * } func findColumnForFirstNonWhitespaceCharacterInLine(line int, char int, sourceFile *ast.SourceFile, options *lsutil.FormatCodeSettings) int { - lineStart := scanner.GetECMAPositionOfLineAndCharacter(sourceFile, line, 0) + lineStart := scanner.GetECMAPositionOfLineAndByteOffset(sourceFile, line, 0) return FindFirstNonWhitespaceColumn(lineStart, lineStart+char, sourceFile, options) } @@ -251,7 +251,7 @@ func childStartsOnTheSameLineWithElseInIfStatement(parent *ast.Node, child *ast. } func getStartLineAndCharacterForNode(n *ast.Node, sourceFile *ast.SourceFile) (line int, character int) { - return scanner.GetECMALineAndCharacterOfPosition(sourceFile, scanner.GetTokenPosOfNode(n, sourceFile, false)) + return scanner.GetECMALineAndByteOffsetOfPosition(sourceFile, scanner.GetTokenPosOfNode(n, sourceFile, false)) } func getStartLineForNode(n *ast.Node, sourceFile *ast.SourceFile) int { @@ -361,7 +361,7 @@ func getContainingListOrParentStart(parent *ast.Node, child *ast.Node, sourceFil } else { startPos = scanner.GetTokenPosOfNode(parent, sourceFile, false) } - return scanner.GetECMALineAndCharacterOfPosition(sourceFile, startPos) + return scanner.GetECMALineAndByteOffsetOfPosition(sourceFile, startPos) } func isControlFlowEndingStatement(kind ast.Kind, parentKind ast.Kind) bool { diff --git a/internal/format/span.go b/internal/format/span.go index ad3df2805f..44153f9ec8 100644 --- a/internal/format/span.go +++ b/internal/format/span.go @@ -264,7 +264,7 @@ func (w *formatSpanWorker) execute(s *formattingScanner) []core.TextChange { } w.indentTriviaItems(remainingTrivia, indentation, true, func(item TextRangeWithKind) { - startLine, startChar := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, item.Loc.Pos()) + startLine, startChar := scanner.GetECMALineAndByteOffsetOfPosition(w.sourceFile, item.Loc.Pos()) w.processRange(item, startLine, startChar, w.enclosingNode, w.enclosingNode, nil) w.insertIndentation(item.Loc.Pos(), indentation, false) }) @@ -770,7 +770,7 @@ func (w *formatSpanWorker) processRange(r TextRangeWithKind, rangeStartLine int, func (w *formatSpanWorker) processTrivia(trivia []TextRangeWithKind, parent *ast.Node, contextNode *ast.Node, dynamicIndentation *dynamicIndenter) { for _, triviaItem := range trivia { if isComment(triviaItem.Kind) && triviaItem.Loc.ContainedBy(w.originalRange) { - triviaItemStartLine, triviaItemStartCharacter := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, triviaItem.Loc.Pos()) + triviaItemStartLine, triviaItemStartCharacter := scanner.GetECMALineAndByteOffsetOfPosition(w.sourceFile, triviaItem.Loc.Pos()) w.processRange(triviaItem, triviaItemStartLine, triviaItemStartCharacter, parent, contextNode, dynamicIndentation) } } @@ -867,7 +867,7 @@ func (w *formatSpanWorker) insertIndentation(pos int, indentation int, lineAdded // insert indentation string at the very beginning of the token w.recordReplace(pos, 0, indentationString) } else { - tokenStartLine, tokenStartCharacter := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, pos) + tokenStartLine, tokenStartCharacter := scanner.GetECMALineAndByteOffsetOfPosition(w.sourceFile, pos) startLinePosition := int(scanner.GetECMALineStarts(w.sourceFile)[tokenStartLine]) if indentation != w.characterToColumn(startLinePosition, tokenStartCharacter) || w.indentationIsDifferent(indentationString, startLinePosition) { w.recordReplace(startLinePosition, tokenStartCharacter, indentationString) @@ -1026,7 +1026,7 @@ func (w *formatSpanWorker) consumeTokenAndAdvanceScanner(currentTokenInfo tokenI lineAction := LineActionNone isTokenInRange := currentTokenInfo.token.Loc.ContainedBy(w.originalRange) - tokenStartLine, tokenStartChar := scanner.GetECMALineAndCharacterOfPosition(w.sourceFile, currentTokenInfo.token.Loc.Pos()) + tokenStartLine, tokenStartChar := scanner.GetECMALineAndByteOffsetOfPosition(w.sourceFile, currentTokenInfo.token.Loc.Pos()) if isTokenInRange { rangeHasError := w.rangeContainsError(currentTokenInfo.token.Loc) diff --git a/internal/printer/textwriter.go b/internal/printer/textwriter.go index a1b92b5302..8b532d9222 100644 --- a/internal/printer/textwriter.go +++ b/internal/printer/textwriter.go @@ -31,11 +31,15 @@ func (w *textWriter) DecreaseIndent() { w.indent-- } +// GetColumn returns the column position measured in UTF-16 code units, +// matching TypeScript's native encoding for source map compatibility. func (w *textWriter) GetColumn() int { if w.lineStart { return w.indent * w.indentSize } - return w.builder.Len() - w.linePos + // Count UTF-16 code units from the last line start. + // For ASCII-only output (the common case), this equals the byte count. + return core.UTF16Len(w.builder.String()[w.linePos:]) } func (w *textWriter) GetIndent() int { diff --git a/internal/printer/utilities.go b/internal/printer/utilities.go index 871e2d3851..b33cfd2182 100644 --- a/internal/printer/utilities.go +++ b/internal/printer/utilities.go @@ -893,8 +893,11 @@ func calculateIndent(text string, pos int, end int) int { // optimized for monotonically increasing positions (e.g., during source map emit). // // When positions increase within the same line, only the delta between the last -// position and the new position needs to be scanned for rune counts, turning -// what would be O(nΒ²) into O(n) for long lines. +// position and the new position needs to be scanned for UTF-16 code unit counts, +// turning what would be O(nΒ²) into O(n) for long lines. +// +// Character offsets are measured in UTF-16 code units, matching TypeScript's +// native encoding and the source map specification. type lineCharacterCache struct { lineMap []core.TextPos text string @@ -911,15 +914,16 @@ func newLineCharacterCache(source sourcemap.Source) *lineCharacterCache { } } +// getLineAndCharacter returns the 0-based line number and UTF-16 code unit +// offset from the start of that line for the given byte position. func (c *lineCharacterCache) getLineAndCharacter(pos int) (line int, character int) { line = scanner.ComputeLineOfPosition(c.lineMap, pos) if c.hasCached && line == c.cachedLine && pos >= c.cachedPos { - // Incremental: only count runes from the last cached position. - character = c.cachedChar + utf8.RuneCountInString(c.text[c.cachedPos:pos]) + // Incremental: only count UTF-16 code units from the last cached position. + character = c.cachedChar + core.UTF16Len(c.text[c.cachedPos:pos]) } else { // Full computation from line start. - // !!! TODO: this is suspect; these are rune counts, not UTF-8 _or_ UTF-16 offsets. - character = utf8.RuneCountInString(c.text[c.lineMap[line]:pos]) + character = core.UTF16Len(c.text[c.lineMap[line]:pos]) } c.cachedLine = line c.cachedPos = pos diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index c10e9ff8f1..5b80e8a69e 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -7,6 +7,7 @@ import ( "strconv" "strings" "unicode" + "unicode/utf16" "unicode/utf8" "github.com/microsoft/typescript-go/internal/ast" @@ -2459,14 +2460,28 @@ func GetECMALineOfPosition(sourceFile ast.SourceFileLike, pos int) int { return ComputeLineOfPosition(lineMap, pos) } +// GetECMALineAndCharacterOfPosition returns the 0-based line number and the +// UTF-16 code unit offset from the start of that line for the given byte position. +// Uses ECMAScript line separators (LF, CR, CRLF, LS, PS). +// This matches TypeScript's native getLineAndCharacterOfPosition. func GetECMALineAndCharacterOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, character int) { lineMap := GetECMALineStarts(sourceFile) line = ComputeLineOfPosition(lineMap, pos) - // !!! TODO: this is suspect; these are rune counts, not UTF-8 _or_ UTF-16 offsets. - character = utf8.RuneCountInString(sourceFile.Text()[lineMap[line]:pos]) + character = core.UTF16Len(sourceFile.Text()[lineMap[line]:pos]) return line, character } +// GetECMALineAndByteOffsetOfPosition returns the 0-based line number and the +// raw UTF-8 byte offset from the start of that line for the given byte position. +// Uses ECMAScript line separators (LF, CR, CRLF, LS, PS). +// Unlike GetECMALineAndCharacterOfPosition, the offset is in bytes, not UTF-16 code units. +func GetECMALineAndByteOffsetOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, byteOffset int) { + lineMap := GetECMALineStarts(sourceFile) + line = ComputeLineOfPosition(lineMap, pos) + byteOffset = pos - int(lineMap[line]) + return line, byteOffset +} + func GetECMAEndLinePosition(sourceFile *ast.SourceFile, line int) int { pos := int(GetECMALineStarts(sourceFile)[line]) for { @@ -2478,14 +2493,49 @@ func GetECMAEndLinePosition(sourceFile *ast.SourceFile, line int) int { } } +// GetECMAPositionOfLineAndCharacter converts a 0-based line number and UTF-16 +// code unit character offset back to an absolute byte position in the source text. +// Uses ECMAScript line separators. func GetECMAPositionOfLineAndCharacter(sourceFile ast.SourceFileLike, line int, character int) int { - return ComputePositionOfLineAndCharacter(GetECMALineStarts(sourceFile), line, character) + lineStarts := GetECMALineStarts(sourceFile) + lineStart := int(lineStarts[line]) + if character == 0 { + return lineStart + } + // Scan from line start counting UTF-16 code units to find the byte position. + text := sourceFile.Text() + utf16Count := 0 + for i, r := range text[lineStart:] { + if utf16Count >= character { + return lineStart + i + } + utf16Count += utf16.RuneLen(r) + } + return len(text) +} + +// GetECMAPositionOfLineAndByteOffset converts a 0-based line number and byte offset +// from line start back to an absolute byte position in the source text. +// Uses ECMAScript line separators. +func GetECMAPositionOfLineAndByteOffset(sourceFile ast.SourceFileLike, line int, byteOffset int) int { + return ComputePositionOfLineAndByteOffset(GetECMALineStarts(sourceFile), line, byteOffset) } -func ComputePositionOfLineAndCharacter(lineStarts []core.TextPos, line int, character int) int { - return ComputePositionOfLineAndCharacterEx(lineStarts, line, character, nil, false) +// ComputePositionOfLineAndByteOffset computes a byte position from a line and +// raw byte offset from the line start. This is a simple addition with validation. +func ComputePositionOfLineAndByteOffset(lineStarts []core.TextPos, line int, byteOffset int) int { + if line < 0 || line >= len(lineStarts) { + panic(fmt.Sprintf("Bad line number. Line: %d, lineStarts.length: %d.", line, len(lineStarts))) + } + return int(lineStarts[line]) + byteOffset } +// ComputePositionOfLineAndCharacterEx converts a line and UTF-16 character offset +// back to a byte position. The character parameter is measured in UTF-16 code units, +// matching the encoding used by TypeScript and source maps. +// When text is provided, it scans from the line start to correctly handle multi-byte characters. +// When text is nil, character is treated as a byte offset (legacy behavior). +// When allowEdits is true, out-of-range values are clamped instead of panicking. func ComputePositionOfLineAndCharacterEx(lineStarts []core.TextPos, line int, character int, text *string, allowEdits bool) int { if line < 0 || line >= len(lineStarts) { if allowEdits { @@ -2500,7 +2550,34 @@ func ComputePositionOfLineAndCharacterEx(lineStarts []core.TextPos, line int, ch } } - res := int(lineStarts[line]) + character + lineStart := int(lineStarts[line]) + + if text != nil && character > 0 { + // UTF-16 character offset: scan from line start counting UTF-16 code units. + lineEnd := len(*text) + if line+1 < len(lineStarts) { + lineEnd = int(lineStarts[line+1]) + } + utf16Count := 0 + pos := lineStart + for pos < lineEnd { + if utf16Count >= character { + break + } + r, size := utf8.DecodeRuneInString((*text)[pos:]) + utf16Count += utf16.RuneLen(r) + pos += size + } + if allowEdits { + if pos > len(*text) { + return len(*text) + } + } + return pos + } + + // No text or character is 0: treat character as byte offset (simple addition). + res := lineStart + character if allowEdits { // Clamp to nearest allowable values to allow the underlying to be edited without crashing (accuracy is lost, instead) diff --git a/internal/testutil/harnessutil/sourcemap_recorder.go b/internal/testutil/harnessutil/sourcemap_recorder.go index c269a89d6c..a83f106aec 100644 --- a/internal/testutil/harnessutil/sourcemap_recorder.go +++ b/internal/testutil/harnessutil/sourcemap_recorder.go @@ -8,6 +8,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/json" + "github.com/microsoft/typescript-go/internal/scanner" "github.com/microsoft/typescript-go/internal/sourcemap" "github.com/microsoft/typescript-go/internal/stringutil" ) @@ -289,7 +290,14 @@ func (sw *recordedSpanWriter) writeSourceMapMarkerEx(currentSpan *sourceMapSpanW } func (sw *recordedSpanWriter) writeSourceMapSourceText(currentSpan *sourceMapSpanWithDecodeErrors, index int) { - sourcePos := int(sw.w.tsLineMap[currentSpan.sourceMapSpan.SourceLine]) + currentSpan.sourceMapSpan.SourceCharacter + // Convert UTF-16 character offset from the source map to a byte position. + sourcePos := scanner.ComputePositionOfLineAndCharacterEx( + sw.w.tsLineMap, + currentSpan.sourceMapSpan.SourceLine, + currentSpan.sourceMapSpan.SourceCharacter, + &sw.w.tsCode, + true, /*allowEdits*/ + ) var sourceText string if sw.w.prevWrittenSourcePos < sourcePos { // Position that goes forward, get text diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.symbols b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.symbols index 60d53f7996..61d271d256 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.symbols +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.symbols @@ -19,10 +19,10 @@ const emoji = "πŸ€·β€β™‚οΈ" >emoji : Symbol(emoji, Decl(declarationEmitLateBoundAssignments2.ts, 6, 5)) export function decl() {} ->decl : Symbol(decl, Decl(declarationEmitLateBoundAssignments2.ts, 6, 20)) +>decl : Symbol(decl, Decl(declarationEmitLateBoundAssignments2.ts, 6, 21)) decl["B"] = 'foo' ->decl : Symbol(decl, Decl(declarationEmitLateBoundAssignments2.ts, 6, 20)) +>decl : Symbol(decl, Decl(declarationEmitLateBoundAssignments2.ts, 6, 21)) >"B" : Symbol(decl["B"], Decl(declarationEmitLateBoundAssignments2.ts, 8, 25)) export function decl2() {} @@ -82,10 +82,10 @@ decl9["πŸ€ͺ"] = 0 >"πŸ€ͺ" : Symbol(decl9["\uD83E\uDD2A"], Decl(declarationEmitLateBoundAssignments2.ts, 32, 26)) export function decl10() {} ->decl10 : Symbol(decl10, Decl(declarationEmitLateBoundAssignments2.ts, 33, 14)) +>decl10 : Symbol(decl10, Decl(declarationEmitLateBoundAssignments2.ts, 33, 15)) decl10[emoji] = 0 ->decl10 : Symbol(decl10, Decl(declarationEmitLateBoundAssignments2.ts, 33, 14)) +>decl10 : Symbol(decl10, Decl(declarationEmitLateBoundAssignments2.ts, 33, 15)) >emoji : Symbol(emoji, Decl(declarationEmitLateBoundAssignments2.ts, 6, 5)) export const arrow = () => {} diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.symbols.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.symbols.diff index 48d64eb4a7..f55a47124c 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.symbols.diff @@ -5,11 +5,11 @@ export function decl() {} ->decl : Symbol(decl, Decl(declarationEmitLateBoundAssignments2.ts, 6, 21), Decl(declarationEmitLateBoundAssignments2.ts, 8, 25)) -+>decl : Symbol(decl, Decl(declarationEmitLateBoundAssignments2.ts, 6, 20)) ++>decl : Symbol(decl, Decl(declarationEmitLateBoundAssignments2.ts, 6, 21)) decl["B"] = 'foo' ->decl : Symbol(decl, Decl(declarationEmitLateBoundAssignments2.ts, 6, 21), Decl(declarationEmitLateBoundAssignments2.ts, 8, 25)) -+>decl : Symbol(decl, Decl(declarationEmitLateBoundAssignments2.ts, 6, 20)) ++>decl : Symbol(decl, Decl(declarationEmitLateBoundAssignments2.ts, 6, 21)) >"B" : Symbol(decl["B"], Decl(declarationEmitLateBoundAssignments2.ts, 8, 25)) export function decl2() {} @@ -86,11 +86,11 @@ export function decl10() {} ->decl10 : Symbol(decl10, Decl(declarationEmitLateBoundAssignments2.ts, 33, 15), Decl(declarationEmitLateBoundAssignments2.ts, 35, 27)) -+>decl10 : Symbol(decl10, Decl(declarationEmitLateBoundAssignments2.ts, 33, 14)) ++>decl10 : Symbol(decl10, Decl(declarationEmitLateBoundAssignments2.ts, 33, 15)) decl10[emoji] = 0 ->decl10 : Symbol(decl10, Decl(declarationEmitLateBoundAssignments2.ts, 33, 15), Decl(declarationEmitLateBoundAssignments2.ts, 35, 27)) -+>decl10 : Symbol(decl10, Decl(declarationEmitLateBoundAssignments2.ts, 33, 14)) ++>decl10 : Symbol(decl10, Decl(declarationEmitLateBoundAssignments2.ts, 33, 15)) >emoji : Symbol(emoji, Decl(declarationEmitLateBoundAssignments2.ts, 6, 5)) export const arrow = () => {} diff --git a/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiers.symbols b/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiers.symbols index ea833ecda8..b51d027149 100644 --- a/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiers.symbols +++ b/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiers.symbols @@ -15,13 +15,13 @@ console.log(𝑀 + π‘š); // 9 >π‘š : Symbol(π‘š, Decl(extendedUnicodePlaneIdentifiers.ts, 0, 5)) class K { ->K : Symbol(K, Decl(extendedUnicodePlaneIdentifiers.ts, 2, 19)) +>K : Symbol(K, Decl(extendedUnicodePlaneIdentifiers.ts, 2, 21)) #π‘š = 4; >#π‘š : Symbol(K.#π‘š, Decl(extendedUnicodePlaneIdentifiers.ts, 4, 9)) #𝑀 = 5; ->#𝑀 : Symbol(K.#𝑀, Decl(extendedUnicodePlaneIdentifiers.ts, 5, 11)) +>#𝑀 : Symbol(K.#𝑀, Decl(extendedUnicodePlaneIdentifiers.ts, 5, 12)) } // lower 8 bits look like 'a' diff --git a/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiers.symbols.diff b/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiers.symbols.diff index dbd66df958..0da974fbfb 100644 --- a/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiers.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiers.symbols.diff @@ -1,11 +1,7 @@ --- old.extendedUnicodePlaneIdentifiers.symbols +++ new.extendedUnicodePlaneIdentifiers.symbols -@@= skipped -14, +14 lines =@@ - >π‘š : Symbol(π‘š, Decl(extendedUnicodePlaneIdentifiers.ts, 0, 5)) - - class K { -->K : Symbol(K, Decl(extendedUnicodePlaneIdentifiers.ts, 2, 21)) -+>K : Symbol(K, Decl(extendedUnicodePlaneIdentifiers.ts, 2, 19)) +@@= skipped -17, +17 lines =@@ + >K : Symbol(K, Decl(extendedUnicodePlaneIdentifiers.ts, 2, 21)) #π‘š = 4; ->#π‘š : Symbol(K[#π‘š], Decl(extendedUnicodePlaneIdentifiers.ts, 4, 9)) @@ -13,7 +9,7 @@ #𝑀 = 5; ->#𝑀 : Symbol(K[#𝑀], Decl(extendedUnicodePlaneIdentifiers.ts, 5, 12)) -+>#𝑀 : Symbol(K.#𝑀, Decl(extendedUnicodePlaneIdentifiers.ts, 5, 11)) ++>#𝑀 : Symbol(K.#𝑀, Decl(extendedUnicodePlaneIdentifiers.ts, 5, 12)) } // lower 8 bits look like 'a' \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.symbols b/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.symbols index 3d9c42644b..8cdc0e81ab 100644 --- a/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.symbols +++ b/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.symbols @@ -9,12 +9,12 @@ function foo(π‘š, 𝑀) { >foo : Symbol(foo, Decl(file.js, 0, 0)) >π‘š : Symbol(π‘š, Decl(file.js, 5, 13)) ->𝑀 : Symbol(𝑀, Decl(file.js, 5, 15)) +>𝑀 : Symbol(𝑀, Decl(file.js, 5, 16)) console.log(𝑀 + π‘š); >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->𝑀 : Symbol(𝑀, Decl(file.js, 5, 15)) +>𝑀 : Symbol(𝑀, Decl(file.js, 5, 16)) >π‘š : Symbol(π‘š, Decl(file.js, 5, 13)) } diff --git a/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.symbols.diff b/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.symbols.diff deleted file mode 100644 index 01bb90f528..0000000000 --- a/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.symbols.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.extendedUnicodePlaneIdentifiersJSDoc.symbols -+++ new.extendedUnicodePlaneIdentifiersJSDoc.symbols -@@= skipped -8, +8 lines =@@ - function foo(π‘š, 𝑀) { - >foo : Symbol(foo, Decl(file.js, 0, 0)) - >π‘š : Symbol(π‘š, Decl(file.js, 5, 13)) -->𝑀 : Symbol(𝑀, Decl(file.js, 5, 16)) -+>𝑀 : Symbol(𝑀, Decl(file.js, 5, 15)) - - console.log(𝑀 + π‘š); - >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) - >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) - >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) -->𝑀 : Symbol(𝑀, Decl(file.js, 5, 16)) -+>𝑀 : Symbol(𝑀, Decl(file.js, 5, 15)) - >π‘š : Symbol(π‘š, Decl(file.js, 5, 13)) - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).js.map b/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).js.map index bec795fb31..a5998d5484 100644 --- a/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).js.map +++ b/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).js.map @@ -1,3 +1,3 @@ //// [sourceMap-LineBreaks.js.map] -{"version":3,"file":"sourceMap-LineBreaks.js","sourceRoot":"","sources":["sourceMap-LineBreaks.ts"],"names":[],"mappings":";AAAA,IAAI,qBAAqB,GAAG,EAAE,CAAC;AAC/B,IAAI,0BAA0B,GAAG,EAAE,CAAC;AACpC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAAC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AACnD,IAAI,8BAA8B,GAAG,CAAC,CAAC;AACvC,IAAI,sBAAsB,GAAG,CAAC,CAAC;AAC/B,IAAI,8BAA8B,GAAG,CAAC,CAAC;AAEvC,IAAI,sCAAsC,GAAG,CAAC,CAAC;AAE/C,IAAI,yBAAyB,GAAG;OACzB,CAAC;AACR,IAAI,uCAAuC,GAAG;OACvC,CAAC;AACR,IAAI,+BAA+B,GAAG;OAC/B,CAAC;AAER,IAAI,8BAA8B,GAAG;OAC9B,CAAC;AACR,IAAI,mCAAmC,GAAG;OACnC,CAAC;AACR,IAAI,yBAAyB,GAAG,iBAAgB,CAAC"} -//// https://sokra.github.io/source-map-visualization#base64,InVzZSBzdHJpY3QiOw0KdmFyIGVuZHNXaXRobGluZVNlcGFyYXRvciA9IDEwOw0KdmFyIGVuZHNXaXRoUGFyYWdyYXBoU2VwYXJhdG9yID0gMTA7DQp2YXIgZW5kc1dpdGhOZXh0TGluZSA9IDE7DQp2YXIgZW5kc1dpdGhMaW5lRmVlZCA9IDE7DQp2YXIgZW5kc1dpdGhDYXJyaWFnZVJldHVybkxpbmVGZWVkID0gMTsNCnZhciBlbmRzV2l0a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5lIDIiO+KAqXZhciBzdHJpbmdMaXRlcmFsV2l0aFBhcmFncmFwaFNlcGFyYXRvciA9ICJsaW5lIDFc4oCpbGluZSAyIjvigKl2YXIgc3RyaW5nTGl0ZXJhbFdpdGhOZXh0TGluZSA9ICJsaW5lIDFcwoVsaW5lIDIiOw== +{"version":3,"file":"sourceMap-LineBreaks.js","sourceRoot":"","sources":["sourceMap-LineBreaks.ts"],"names":[],"mappings":";AAAA,IAAI,qBAAqB,GAAG,EAAE,CAAC;AAC/B,IAAI,0BAA0B,GAAG,EAAE,CAAC;AACpC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAAC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AACnD,IAAI,8BAA8B,GAAG,CAAC,CAAC;AACvC,IAAI,sBAAsB,GAAG,CAAC,CAAC;AAC/B,IAAI,8BAA8B,GAAG,CAAC,CAAC;AAEvC,IAAI,sCAAsC,GAAG,CAAC,CAAC;AAE/C,IAAI,yBAAyB,GAAG;OACzB,CAAC;AACR,IAAI,uCAAuC,GAAG;OACvC,CAAC;AACR,IAAI,+BAA+B,GAAG;OAC/B,CAAC;AAER,IAAI,8BAA8B,GAAG;OAC9B,CAAC;AACR,IAAI,mCAAmC,GAAG;OACnC,CAAC;AACR,IAAI,yBAAyB,GAAG,gBAAgB,CAAC"} +//// https://sokra.github.io/source-map-visualization#base64,InVzZSBzdHJpY3QiOw0KdmFyIGVuZHNXaXRobGluZVNlcGFyYXRvciA9IDEwOw0KdmFyIGVuZHNXaXRoUGFyYWdyYXBoU2VwYXJhdG9yID0gMTA7DQp2YXIgZW5kc1dpdGhOZXh0TGluZSA9IDE7DQp2YXIgZW5kc1dpdGhMaW5lRmVlZCA9IDE7DQp2YXIgZW5kc1dpdGhDYXJyaWFnZVJldHVybkxpbmVGZWVkID0gMTsNCnZhciBlbmRzV2l0aENhcnJpYWdlUmV0dXJuID0gMTsNCnZhciBlbmRzV2l0aExpbmVGZWVkQ2FycmlhZ2VSZXR1cm4gPS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c4oCpbGluZSAyIjvigKl2YXIgc3RyaW5nTGl0ZXJhbFdpdGhOZXh0TGluZSA9ICJsaW5lIDFcwoVsaW5lIDIiOw== diff --git a/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).js.map.diff b/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).js.map.diff deleted file mode 100644 index 86127623b2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).js.map.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.sourceMap-LineBreaks(target=es2015).js.map -+++ new.sourceMap-LineBreaks(target=es2015).js.map -@@= skipped -0, +0 lines =@@ - //// [sourceMap-LineBreaks.js.map] --{"version":3,"file":"sourceMap-LineBreaks.js","sourceRoot":"","sources":["sourceMap-LineBreaks.ts"],"names":[],"mappings":";AAAA,IAAI,qBAAqB,GAAG,EAAE,CAAC;AAC/B,IAAI,0BAA0B,GAAG,EAAE,CAAC;AACpC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAAC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AACnD,IAAI,8BAA8B,GAAG,CAAC,CAAC;AACvC,IAAI,sBAAsB,GAAG,CAAC,CAAC;AAC/B,IAAI,8BAA8B,GAAG,CAAC,CAAC;AAEvC,IAAI,sCAAsC,GAAG,CAAC,CAAC;AAE/C,IAAI,yBAAyB,GAAG;OACzB,CAAC;AACR,IAAI,uCAAuC,GAAG;OACvC,CAAC;AACR,IAAI,+BAA+B,GAAG;OAC/B,CAAC;AAER,IAAI,8BAA8B,GAAG;OAC9B,CAAC;AACR,IAAI,mCAAmC,GAAG;OACnC,CAAC;AACR,IAAI,yBAAyB,GAAG,gBAAgB,CAAC"} --//// https://sokra.github.io/source-map-visualization#base64,InVzZSBzdHJpY3QiOw0KdmFyIGVuZHNXaXRobGluZVNlcGFyYXRvciA9IDEwOw0KdmFyIGVuZHNXaXRoUGFyYWdyYXBoU2VwYXJhdG9yID0gMTA7DQ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Igc3RyaW5nTGl0ZXJhbFdpdGhDYXJyaWFnZVJldHVybiA9ICJsaW5lIDFcCmxpbmUgMiI7Cgp2YXIgc3RyaW5nTGl0ZXJhbFdpdGhMaW5lU2VwYXJhdG9yID0gImxpbmUgMVzigKhsaW5lIDIiO+KAqXZhciBzdHJpbmdMaXRlcmFsV2l0aFBhcmFncmFwaFNlcGFyYXRvciA9ICJsaW5lIDFc4oCpbGluZSAyIjvigKl2YXIgc3RyaW5nTGl0ZXJhbFdpdGhOZXh0TGluZSA9ICJsaW5lIDFcwoVsaW5lIDIiOw== -+{"version":3,"file":"sourceMap-LineBreaks.js","sourceRoot":"","sources":["sourceMap-LineBreaks.ts"],"names":[],"mappings":";AAAA,IAAI,qBAAqB,GAAG,EAAE,CAAC;AAC/B,IAAI,0BAA0B,GAAG,EAAE,CAAC;AACpC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAAC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AACnD,IAAI,8BAA8B,GAAG,CAAC,CAAC;AACvC,IAAI,sBAAsB,GAAG,CAAC,CAAC;AAC/B,IAAI,8BAA8B,GAAG,CAAC,CAAC;AAEvC,IAAI,sCAAsC,GAAG,CAAC,CAAC;AAE/C,IAAI,yBAAyB,GAAG;OACzB,CAAC;AACR,IAAI,uCAAuC,GAAG;OACvC,CAAC;AACR,IAAI,+BAA+B,GAAG;OAC/B,CAAC;AAER,IAAI,8BAA8B,GAAG;OAC9B,CAAC;AACR,IAAI,mCAAmC,GAAG;OACnC,CAAC;AACR,IAAI,yBAAyB,GAAG,iBAAgB,CAAC"} -+//// https://sokra.github.io/source-map-visualization#base64,InVzZSBzdHJpY3QiOw0KdmFyIGVuZHNXaXRobGluZVNlcGFyYXRvciA9IDEwOw0KdmFyIGVuZHNXaXRoUGFyYWdyYXBoU2VwYXJhdG9yID0gMTA7DQp2YXIgZW5kc1dpdGhOZXh0TGluZSA9IDE7DQp2YXIgZW5kc1dpdGhMaW5lRmVlZCA9IDE7DQp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p2YXIgc3RyaW5nTGl0ZXJhbFdpdGhMaW5lU2VwYXJhdG9yID0gImxpbmUgMVzigKhsaW5lIDIiO+KAqXZhciBzdHJpbmdMaXRlcmFsV2l0aFBhcmFncmFwaFNlcGFyYXRvciA9ICJsaW5lIDFc4oCpbGluZSAyIjvigKl2YXIgc3RyaW5nTGl0ZXJhbFdpdGhOZXh0TGluZSA9ICJsaW5lIDFcwoVsaW5lIDIiOw== \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).sourcemap.txt b/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).sourcemap.txt index 19d3526827..fe2fbcae32 100644 --- a/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).sourcemap.txt +++ b/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).sourcemap.txt @@ -79,12 +79,12 @@ sourceFile:sourceMap-LineBreaks.ts 5 > ^ 6 > ^ 7 > ^^^^^^^^^^^^^^^-> -1->Β -2 >…var -3 > endsWithLineFee -4 > d = -5 > -6 > 1 +1->Β… +2 >var +3 > endsWithLineFeed +4 > = +5 > 1 +6 > ; 1->Emitted(5, 1) Source(3, 27) + SourceIndex(0) 2 >Emitted(5, 5) Source(3, 31) + SourceIndex(0) 3 >Emitted(5, 21) Source(3, 47) + SourceIndex(0) @@ -99,7 +99,7 @@ sourceFile:sourceMap-LineBreaks.ts 4 > ^^^ 5 > ^ 6 > ^ -1->; +1-> > 2 >var 3 > endsWithCarriageReturnLineFeed @@ -306,19 +306,19 @@ sourceFile:sourceMap-LineBreaks.ts 2 >^^^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^ 4 > ^^^ -5 > ^^^^^^^^^^^^^^^^^ -6 > ^ +5 > ^^^^^^^^^^^^^^^^ +6 > ^ 1->
 > 2 >var 3 > stringLiteralWithNextLine 4 > = -5 > "line 1\Β…line 2 -6 > " +5 > "line 1\Β…line 2" +6 > ; 1->Emitted(20, 1) Source(21, 1) + SourceIndex(0) 2 >Emitted(20, 5) Source(21, 5) + SourceIndex(0) 3 >Emitted(20, 30) Source(21, 30) + SourceIndex(0) 4 >Emitted(20, 33) Source(21, 33) + SourceIndex(0) -5 >Emitted(20, 50) Source(21, 49) + SourceIndex(0) -6 >Emitted(20, 51) Source(21, 50) + SourceIndex(0) +5 >Emitted(20, 49) Source(21, 49) + SourceIndex(0) +6 >Emitted(20, 50) Source(21, 50) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMap-LineBreaks.js.map \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).sourcemap.txt.diff b/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).sourcemap.txt.diff index f5d3d7660a..c2b777146c 100644 --- a/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).sourcemap.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/sourceMap-LineBreaks(target=es2015).sourcemap.txt.diff @@ -1,34 +1,6 @@ --- old.sourceMap-LineBreaks(target=es2015).sourcemap.txt +++ new.sourceMap-LineBreaks(target=es2015).sourcemap.txt -@@= skipped -78, +78 lines =@@ - 5 > ^ - 6 > ^ - 7 > ^^^^^^^^^^^^^^^-> --1->Β… --2 >var --3 > endsWithLineFeed --4 > = --5 > 1 --6 > ; -+1->Β -+2 >…var -+3 > endsWithLineFee -+4 > d = -+5 > -+6 > 1 - 1->Emitted(5, 1) Source(3, 27) + SourceIndex(0) - 2 >Emitted(5, 5) Source(3, 31) + SourceIndex(0) - 3 >Emitted(5, 21) Source(3, 47) + SourceIndex(0) -@@= skipped -20, +20 lines =@@ - 4 > ^^^ - 5 > ^ - 6 > ^ --1-> -+1->; - > - 2 >var - 3 > endsWithCarriageReturnLineFeed -@@= skipped -149, +149 lines =@@ +@@= skipped -247, +247 lines =@@ >>>line 2"; 1 >^^^^^^^ 2 > ^ @@ -54,30 +26,4 @@ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >"line 1\
 >line 2" 2 > ; - 1 >Emitted(19, 8) Source(20, 8) + SourceIndex(0) -@@= skipped -11, +11 lines =@@ - 2 >^^^^ - 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^ - 4 > ^^^ --5 > ^^^^^^^^^^^^^^^^ --6 > ^ -+5 > ^^^^^^^^^^^^^^^^^ -+6 > ^ - 1->
 > - 2 >var - 3 > stringLiteralWithNextLine - 4 > = --5 > "line 1\Β…line 2" --6 > ; -+5 > "line 1\Β…line 2 -+6 > " - 1->Emitted(20, 1) Source(21, 1) + SourceIndex(0) - 2 >Emitted(20, 5) Source(21, 5) + SourceIndex(0) - 3 >Emitted(20, 30) Source(21, 30) + SourceIndex(0) - 4 >Emitted(20, 33) Source(21, 33) + SourceIndex(0) --5 >Emitted(20, 49) Source(21, 49) + SourceIndex(0) --6 >Emitted(20, 50) Source(21, 50) + SourceIndex(0) -+5 >Emitted(20, 50) Source(21, 49) + SourceIndex(0) -+6 >Emitted(20, 51) Source(21, 50) + SourceIndex(0) - --- - >>>//# sourceMappingURL=sourceMap-LineBreaks.js.map \ No newline at end of file + 1 >Emitted(19, 8) Source(20, 8) + SourceIndex(0) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).errors.txt b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).errors.txt index 4e4cb21aab..a6ba7c04e9 100644 --- a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).errors.txt @@ -1,7 +1,7 @@ -astralAsSurrogatePair.ts(1,16): error TS1127: Invalid character. -astralAsSurrogatePair.ts(1,17): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uD800'. -astralAsSurrogatePair.ts(1,22): error TS1127: Invalid character. -astralAsSurrogatePair.ts(1,23): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uDEA7'. +astralAsSurrogatePair.ts(1,17): error TS1127: Invalid character. +astralAsSurrogatePair.ts(1,18): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uD800'. +astralAsSurrogatePair.ts(1,23): error TS1127: Invalid character. +astralAsSurrogatePair.ts(1,24): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uDEA7'. ==== extendedEscapesForAstralsInVarsAndClasses.ts (0 errors) ==== diff --git a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).errors.txt.diff index 90e97ba287..016bf7dc8d 100644 --- a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).errors.txt.diff @@ -1,17 +1,5 @@ --- old.unicodeEscapesInNames02(target=es2015).errors.txt +++ new.unicodeEscapesInNames02(target=es2015).errors.txt -@@= skipped -0, +0 lines =@@ --astralAsSurrogatePair.ts(1,17): error TS1127: Invalid character. --astralAsSurrogatePair.ts(1,18): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uD800'. --astralAsSurrogatePair.ts(1,23): error TS1127: Invalid character. --astralAsSurrogatePair.ts(1,24): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uDEA7'. -+astralAsSurrogatePair.ts(1,16): error TS1127: Invalid character. -+astralAsSurrogatePair.ts(1,17): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uD800'. -+astralAsSurrogatePair.ts(1,22): error TS1127: Invalid character. -+astralAsSurrogatePair.ts(1,23): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uDEA7'. - - - ==== extendedEscapesForAstralsInVarsAndClasses.ts (0 errors) ==== @@= skipped -31, +31 lines =@@ ==== astralAsSurrogatePair.ts (4 errors) ==== diff --git a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).js.map b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).js.map index e4525fa34e..5bff538ed4 100644 --- a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).js.map +++ b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).js.map @@ -1,6 +1,6 @@ //// [extendedEscapesForAstralsInVarsAndClasses.js.map] -{"version":3,"file":"extendedEscapesForAstralsInVarsAndClasses.js","sourceRoot":"","sources":["extendedEscapesForAstralsInVarsAndClasses.ts"],"names":[],"mappings":"AAIA,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;IAChB,IAAC,GAAG,OAAO,CAAC;AAChB,CAAC;KACI,CAAC;IACF,SAAS,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,MAAM,GAAG;IACL,SAAS,CAAS;IAClB,cAAc;QACV,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAAA,CAC7B;IACD,OAAO,GAAG;QACN,OAAO,IAAI,CAAC,IAAC,CAAC;IAAA,CACjB;CACJ;AAED,MAAM,CAAC,IAAI,KAAE,GAAG,IAAI,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AAE1D,UAAU,IAAI,GAAG,CAAC"} -//// https://sokra.github.io/source-map-visualization#base64,aWYgKE1hdGgucmFuZG9tKCkpIHsNCiAgICDwkIqnID0gImhlbGxvIjsNCn0NCmVsc2Ugew0KICAgIFx1ezEwMkE3fSA9ICJoYWxsbyI7DQp9DQpjbGFzcyBGb28gew0KICAgIFx1ezEwMkE3fTsNCiAgICBjb25zdHJ1Y3RvcigpIHsNCiAgICAgICAgdGhpcy5cdXsxMDJBN30gPSAiIHdvcmxkIj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TEVUVEVSIEEyCmRlY2xhcmUgdmFyIPCQiqc6IHN0cmluZzsKZGVjbGFyZSB2YXIgXHV7MTAyQTd9OiBzdHJpbmc7CgppZiAoTWF0aC5yYW5kb20oKSkgewogICAg8JCKpyA9ICJoZWxsbyI7Cn0KZWxzZSB7CiAgICBcdXsxMDJBN30gPSAiaGFsbG8iOwp9CgpjbGFzcyBGb28gewogICAgXHV7MTAyQTd9OiBzdHJpbmc7CiAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICB0aGlzLlx1ezEwMkE3fSA9ICIgd29ybGQiOwogICAgfQogICAgbWV0aG9kQSgpIHsKICAgICAgICByZXR1cm4gdGhpcy7wkIqnOwogICAgfQp9CgpleHBvcnQgdmFyIF/wkIqnID0gbmV3IEZvbygpLlx1ezEwMkE3fSArIG5ldyBGb28oKS5tZXRob2RBKCk7CgpfXHV7MTAyQTd9ICs9ICIhIjsK +{"version":3,"file":"extendedEscapesForAstralsInVarsAndClasses.js","sourceRoot":"","sources":["extendedEscapesForAstralsInVarsAndClasses.ts"],"names":[],"mappings":"AAIA,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;IAChB,EAAE,GAAG,OAAO,CAAC;AACjB,CAAC;KACI,CAAC;IACF,SAAS,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,MAAM,GAAG;IACL,SAAS,CAAS;IAClB,cAAc;QACV,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAAA,CAC7B;IACD,OAAO,GAAG;QACN,OAAO,IAAI,CAAC,EAAE,CAAC;IAAA,CAClB;CACJ;AAED,MAAM,CAAC,IAAI,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AAE3D,UAAU,IAAI,GAAG,CAAC"} +//// https://sokra.github.io/source-map-visualization#base64,aWYgKE1hdGgucmFuZG9tKCkpIHsNCiAgICDwkIqnID0gImhlbGxvIjsNCn0NCmVsc2Ugew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ElBQUksR0FBRyxFQUFFLENBQUMsU0FBUyxHQUFHLElBQUksR0FBRyxFQUFFLENBQUMsT0FBTyxFQUFFLENBQUM7QUFFM0QsVUFBVSxJQUFJLEdBQUcsQ0FBQyJ9,Ly8gVSsxMDJBNyBDQVJJQU4gTEVUVEVSIEEyCmRlY2xhcmUgdmFyIPCQiqc6IHN0cmluZzsKZGVjbGFyZSB2YXIgXHV7MTAyQTd9OiBzdHJpbmc7CgppZiAoTWF0aC5yYW5kb20oKSkgewogICAg8JCKpyA9ICJoZWxsbyI7Cn0KZWxzZSB7CiAgICBcdXsxMDJBN30gPSAiaGFsbG8iOwp9CgpjbGFzcyBGb28gewogICAgXHV7MTAyQTd9OiBzdHJpbmc7CiAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICB0aGlzLlx1ezEwMkE3fSA9ICIgd29ybGQiOwogICAgfQogICAgbWV0aG9kQSgpIHsKICAgICAgICByZXR1cm4gdGhpcy7wkIqnOwogICAgfQp9CgpleHBvcnQgdmFyIF/wkIqnID0gbmV3IEZvbygpLlx1ezEwMkE3fSArIG5ldyBGb28oKS5tZXRob2RBKCk7CgpfXHV7MTAyQTd9ICs9ICIhIjsK //// [astralAsSurrogatePair.js.map] {"version":3,"file":"astralAsSurrogatePair.js","sourceRoot":"","sources":["astralAsSurrogatePair.ts"],"names":[],"mappings":""} diff --git a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).js.map.diff b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).js.map.diff index 617b6936d6..5776ca3562 100644 --- a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).js.map.diff +++ b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).js.map.diff @@ -4,8 +4,8 @@ //// [extendedEscapesForAstralsInVarsAndClasses.js.map] -{"version":3,"file":"extendedEscapesForAstralsInVarsAndClasses.js","sourceRoot":"","sources":["extendedEscapesForAstralsInVarsAndClasses.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sxMDJBN30gKz0gIiEiOwo= -+{"version":3,"file":"extendedEscapesForAstralsInVarsAndClasses.js","sourceRoot":"","sources":["extendedEscapesForAstralsInVarsAndClasses.ts"],"names":[],"mappings":"AAIA,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;IAChB,IAAC,GAAG,OAAO,CAAC;AAChB,CAAC;KACI,CAAC;IACF,SAAS,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,MAAM,GAAG;IACL,SAAS,CAAS;IAClB,cAAc;QACV,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAAA,CAC7B;IACD,OAAO,GAAG;QACN,OAAO,IAAI,CAAC,IAAC,CAAC;IAAA,CACjB;CACJ;AAED,MAAM,CAAC,IAAI,KAAE,GAAG,IAAI,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AAE1D,UAAU,IAAI,GAAG,CAAC"} -+//// https://sokra.github.io/source-map-visualization#base64,aWYgKE1hdGgucmFuZG9tKCkpIHsNCiAgICDwkIqnID0gImhlbGxvIjsNCn0NCmVsc2Ugew0KICAgIFx1ezEwMkE3fSA9ICJoYWxsbyI7DQp9DQpjbGFzcyBGb28gew0KICAgIFx1ezEwMkE3fTsNCiAgICBjb25zdHJ1Y3RvcigpIHsNCiAgICAgICAgdGhpcy5cdXsxMDJBN30gPSAiIHdvcmxkIjsNCiAgICB9DQogICAgbWV0aG9kQSgpIHsNCiAgICAgICAgcmV0dXJuIHRoaXMu8JCKpzsNCiAgICB9DQp9DQpleHBvcnQgdmFyIF/wkIqnID0gbmV3IEZvbygpLlx1ezEwMkE3fSArIG5ldyBGb28oKS5tZXRob2RBKCk7DQpfXHV7MTAyQTd9ICs9ICIhIjsNCi8vIyBzb3VyY2VNYXBwaW5nVVJMPWV4dGVuZGVkRXNjYXBlc0ZvckFzdHJhbHNJblZhcnNBbmRDbGFzc2VzLmpzLm1hcA==,eyJ2ZXJzaW9uIjozLCJmaWx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gfQogICAgbWV0aG9kQSgpIHsKICAgICAgICByZXR1cm4gdGhpcy7wkIqnOwogICAgfQp9CgpleHBvcnQgdmFyIF/wkIqnID0gbmV3IEZvbygpLlx1ezEwMkE3fSArIG5ldyBGb28oKS5tZXRob2RBKCk7CgpfXHV7MTAyQTd9ICs9ICIhIjsK ++{"version":3,"file":"extendedEscapesForAstralsInVarsAndClasses.js","sourceRoot":"","sources":["extendedEscapesForAstralsInVarsAndClasses.ts"],"names":[],"mappings":"AAIA,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;IAChB,EAAE,GAAG,OAAO,CAAC;AACjB,CAAC;KACI,CAAC;IACF,SAAS,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,MAAM,GAAG;IACL,SAAS,CAAS;IAClB,cAAc;QACV,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAAA,CAC7B;IACD,OAAO,GAAG;QACN,OAAO,IAAI,CAAC,EAAE,CAAC;IAAA,CAClB;CACJ;AAED,MAAM,CAAC,IAAI,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AAE3D,UAAU,IAAI,GAAG,CAAC"} ++//// https://sokra.github.io/source-map-visualization#base64,aWYgKE1hdGgucmFuZG9tKCkpIHsNCiAgICDwkIqnID0gImhlbGxvIjsNCn0NCmVsc2Ugew0KICAgIFx1ezEwMkE3fSA9ICJoYWxsbyI7DQp9DQpjbGFzcyBGb28gew0KICAgIFx1ezEwMkE3fTsNCiAgICBjb25zdHJ1Y3RvcigpIHsNCiAgICAgICAgdGhpcy5cdXsxMDJBN30gPSAiIHdvcmxkIjsNCiAgICB9DQogICAgbWV0aG9kQSgpIHsNCiAgICAgICAgcmV0dXJuIHRoaXMu8JCKpzsNCiAgICB9DQp9DQpleHBvcnQgdmFyIF/wkIqnID0gbmV3IEZvbygpLlx1ezEwMkE3fSArIG5ldyBGb28oKS5tZXRob2RBKCk7D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ICBcdXsxMDJBN30gPSAiaGFsbG8iOwp9CgpjbGFzcyBGb28gewogICAgXHV7MTAyQTd9OiBzdHJpbmc7CiAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICB0aGlzLlx1ezEwMkE3fSA9ICIgd29ybGQiOwogICAgfQogICAgbWV0aG9kQSgpIHsKICAgICAgICByZXR1cm4gdGhpcy7wkIqnOwogICAgfQp9CgpleHBvcnQgdmFyIF/wkIqnID0gbmV3IEZvbygpLlx1ezEwMkE3fSArIG5ldyBGb28oKS5tZXRob2RBKCk7CgpfXHV7MTAyQTd9ICs9ICIhIjsK //// [astralAsSurrogatePair.js.map] {"version":3,"file":"astralAsSurrogatePair.js","sourceRoot":"","sources":["astralAsSurrogatePair.ts"],"names":[],"mappings":""} diff --git a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).sourcemap.txt b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).sourcemap.txt index 9581a71b60..96829aaa23 100644 --- a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).sourcemap.txt +++ b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).sourcemap.txt @@ -40,27 +40,27 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts --- >>> 𐊧 = "hello"; 1 >^^^^ -2 > ^^^^ -3 > ^^^ -4 > ^^^^^^^ -5 > ^ +2 > ^^ +3 > ^^^ +4 > ^^^^^^^ +5 > ^ 1 > > -2 > π -3 > Š§ -4 > = "hel -5 > l +2 > 𐊧 +3 > = +4 > "hello" +5 > ; 1 >Emitted(2, 5) Source(6, 5) + SourceIndex(0) -2 >Emitted(2, 9) Source(6, 6) + SourceIndex(0) -3 >Emitted(2, 12) Source(6, 9) + SourceIndex(0) -4 >Emitted(2, 19) Source(6, 16) + SourceIndex(0) -5 >Emitted(2, 20) Source(6, 17) + SourceIndex(0) +2 >Emitted(2, 7) Source(6, 7) + SourceIndex(0) +3 >Emitted(2, 10) Source(6, 10) + SourceIndex(0) +4 >Emitted(2, 17) Source(6, 17) + SourceIndex(0) +5 >Emitted(2, 18) Source(6, 18) + SourceIndex(0) --- >>>} 1 > 2 >^ 3 > ^^^^^^-> -1 >o"; +1 > > 2 >} 1 >Emitted(3, 1) Source(7, 1) + SourceIndex(0) @@ -193,29 +193,29 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 2 > ^^^^^^^ 3 > ^^^^ 4 > ^ -5 > ^^^^ -6 > ^ +5 > ^^ +6 > ^ 1->{ > 2 > return 3 > this 4 > . -5 > π -6 >  +5 > 𐊧 +6 > ; 1->Emitted(13, 9) Source(18, 9) + SourceIndex(0) 2 >Emitted(13, 16) Source(18, 16) + SourceIndex(0) 3 >Emitted(13, 20) Source(18, 20) + SourceIndex(0) 4 >Emitted(13, 21) Source(18, 21) + SourceIndex(0) -5 >Emitted(13, 25) Source(18, 22) + SourceIndex(0) -6 >Emitted(13, 26) Source(18, 23) + SourceIndex(0) +5 >Emitted(13, 23) Source(18, 23) + SourceIndex(0) +6 >Emitted(13, 24) Source(18, 24) + SourceIndex(0) --- >>> } 1 >^^^^ 2 > ^ 1 > -2 > Ч; +2 > > } -1 >Emitted(14, 5) Source(18, 23) + SourceIndex(0) +1 >Emitted(14, 5) Source(18, 24) + SourceIndex(0) 2 >Emitted(14, 6) Source(19, 6) + SourceIndex(0) --- >>>} @@ -230,61 +230,61 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 2 >^^^^^^ 3 > ^ 4 > ^^^^ -5 > ^^^^^ -6 > ^^^ -7 > ^^^^ -8 > ^^^ -9 > ^^ -10> ^ -11> ^^^^^^^^^ -12> ^^^ -13> ^^^^ -14> ^^^ -15> ^^ -16> ^ -17> ^^^^^^^ -18> ^^ -19> ^ +5 > ^^^ +6 > ^^^ +7 > ^^^^ +8 > ^^^ +9 > ^^ +10> ^ +11> ^^^^^^^^^ +12> ^^^ +13> ^^^^ +14> ^^^ +15> ^^ +16> ^ +17> ^^^^^^^ +18> ^^ +19> ^ 1-> > > 2 >export 3 > 4 > var -5 > _π -6 > Š§ -7 > = n -8 > ew -9 > Fo -10> o -11> ().\u{102 -12> A7} -13> + n -14> ew -15> Fo -16> o -17> ().meth -18> od -19> A +5 > _𐊧 +6 > = +7 > new +8 > Foo +9 > () +10> . +11> \u{102A7} +12> + +13> new +14> Foo +15> () +16> . +17> methodA +18> () +19> ; 1->Emitted(16, 1) Source(22, 1) + SourceIndex(0) 2 >Emitted(16, 7) Source(22, 7) + SourceIndex(0) 3 >Emitted(16, 8) Source(22, 8) + SourceIndex(0) 4 >Emitted(16, 12) Source(22, 12) + SourceIndex(0) -5 >Emitted(16, 17) Source(22, 14) + SourceIndex(0) -6 >Emitted(16, 20) Source(22, 17) + SourceIndex(0) -7 >Emitted(16, 24) Source(22, 21) + SourceIndex(0) -8 >Emitted(16, 27) Source(22, 24) + SourceIndex(0) -9 >Emitted(16, 29) Source(22, 26) + SourceIndex(0) -10>Emitted(16, 30) Source(22, 27) + SourceIndex(0) -11>Emitted(16, 39) Source(22, 36) + SourceIndex(0) -12>Emitted(16, 42) Source(22, 39) + SourceIndex(0) -13>Emitted(16, 46) Source(22, 43) + SourceIndex(0) -14>Emitted(16, 49) Source(22, 46) + SourceIndex(0) -15>Emitted(16, 51) Source(22, 48) + SourceIndex(0) -16>Emitted(16, 52) Source(22, 49) + SourceIndex(0) -17>Emitted(16, 59) Source(22, 56) + SourceIndex(0) -18>Emitted(16, 61) Source(22, 58) + SourceIndex(0) -19>Emitted(16, 62) Source(22, 59) + SourceIndex(0) +5 >Emitted(16, 15) Source(22, 15) + SourceIndex(0) +6 >Emitted(16, 18) Source(22, 18) + SourceIndex(0) +7 >Emitted(16, 22) Source(22, 22) + SourceIndex(0) +8 >Emitted(16, 25) Source(22, 25) + SourceIndex(0) +9 >Emitted(16, 27) Source(22, 27) + SourceIndex(0) +10>Emitted(16, 28) Source(22, 28) + SourceIndex(0) +11>Emitted(16, 37) Source(22, 37) + SourceIndex(0) +12>Emitted(16, 40) Source(22, 40) + SourceIndex(0) +13>Emitted(16, 44) Source(22, 44) + SourceIndex(0) +14>Emitted(16, 47) Source(22, 47) + SourceIndex(0) +15>Emitted(16, 49) Source(22, 49) + SourceIndex(0) +16>Emitted(16, 50) Source(22, 50) + SourceIndex(0) +17>Emitted(16, 57) Source(22, 57) + SourceIndex(0) +18>Emitted(16, 59) Source(22, 59) + SourceIndex(0) +19>Emitted(16, 60) Source(22, 60) + SourceIndex(0) --- >>>_\u{102A7} += "!"; 1 > @@ -293,7 +293,7 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 4 > ^^^ 5 > ^ 6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >(); +1 > > > 2 >_\u{102A7} diff --git a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).sourcemap.txt.diff b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).sourcemap.txt.diff index 880ccc77c8..ad636bf757 100644 --- a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).sourcemap.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).sourcemap.txt.diff @@ -1,47 +1,6 @@ --- old.unicodeEscapesInNames02(target=es2015).sourcemap.txt +++ new.unicodeEscapesInNames02(target=es2015).sourcemap.txt -@@= skipped -39, +39 lines =@@ - --- - >>> 𐊧 = "hello"; - 1 >^^^^ --2 > ^^ --3 > ^^^ --4 > ^^^^^^^ --5 > ^ -+2 > ^^^^ -+3 > ^^^ -+4 > ^^^^^^^ -+5 > ^ - 1 > - > --2 > 𐊧 --3 > = --4 > "hello" --5 > ; -+2 > π -+3 > Š§ -+4 > = "hel -+5 > l - 1 >Emitted(2, 5) Source(6, 5) + SourceIndex(0) --2 >Emitted(2, 7) Source(6, 7) + SourceIndex(0) --3 >Emitted(2, 10) Source(6, 10) + SourceIndex(0) --4 >Emitted(2, 17) Source(6, 17) + SourceIndex(0) --5 >Emitted(2, 18) Source(6, 18) + SourceIndex(0) -+2 >Emitted(2, 9) Source(6, 6) + SourceIndex(0) -+3 >Emitted(2, 12) Source(6, 9) + SourceIndex(0) -+4 >Emitted(2, 19) Source(6, 16) + SourceIndex(0) -+5 >Emitted(2, 20) Source(6, 17) + SourceIndex(0) - --- - >>>} - 1 > - 2 >^ - 3 > ^^^^^^-> --1 > -+1 >o"; - > - 2 >} - 1 >Emitted(3, 1) Source(7, 1) + SourceIndex(0) -@@= skipped -68, +68 lines =@@ +@@= skipped -107, +107 lines =@@ 1-> 2 >^^^^^^ 3 > ^^^ @@ -144,35 +103,30 @@ --- >>> return this.𐊧; 1->^^^^^^^^ - 2 > ^^^^^^^ - 3 > ^^^^ +@@= skipped -35, +38 lines =@@ 4 > ^ --5 > ^^ --6 > ^ + 5 > ^^ + 6 > ^ -1->() { -+5 > ^^^^ -+6 > ^ +1->{ > 2 > return 3 > this 4 > . --5 > 𐊧 --6 > ; + 5 > 𐊧 + 6 > ; -1->Emitted(12, 9) Source(18, 9) + SourceIndex(0) -2 >Emitted(12, 16) Source(18, 16) + SourceIndex(0) -3 >Emitted(12, 20) Source(18, 20) + SourceIndex(0) -4 >Emitted(12, 21) Source(18, 21) + SourceIndex(0) -5 >Emitted(12, 23) Source(18, 23) + SourceIndex(0) -6 >Emitted(12, 24) Source(18, 24) + SourceIndex(0) -+5 > π -+6 >  +1->Emitted(13, 9) Source(18, 9) + SourceIndex(0) +2 >Emitted(13, 16) Source(18, 16) + SourceIndex(0) +3 >Emitted(13, 20) Source(18, 20) + SourceIndex(0) +4 >Emitted(13, 21) Source(18, 21) + SourceIndex(0) -+5 >Emitted(13, 25) Source(18, 22) + SourceIndex(0) -+6 >Emitted(13, 26) Source(18, 23) + SourceIndex(0) ++5 >Emitted(13, 23) Source(18, 23) + SourceIndex(0) ++6 >Emitted(13, 24) Source(18, 24) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -182,9 +136,9 @@ -2 > } -1 >Emitted(13, 5) Source(19, 5) + SourceIndex(0) -2 >Emitted(13, 6) Source(19, 6) + SourceIndex(0) -+2 > Ч; ++2 > + > } -+1 >Emitted(14, 5) Source(18, 23) + SourceIndex(0) ++1 >Emitted(14, 5) Source(18, 24) + SourceIndex(0) +2 >Emitted(14, 6) Source(19, 6) + SourceIndex(0) --- >>>} @@ -198,60 +152,10 @@ --- >>>export var _𐊧 = new Foo().\u{102A7} + new Foo().methodA(); 1-> - 2 >^^^^^^ - 3 > ^ - 4 > ^^^^ --5 > ^^^ --6 > ^^^ --7 > ^^^^ --8 > ^^^ --9 > ^^ --10> ^ --11> ^^^^^^^^^ --12> ^^^ --13> ^^^^ --14> ^^^ --15> ^^ --16> ^ --17> ^^^^^^^ --18> ^^ --19> ^ -+5 > ^^^^^ -+6 > ^^^ -+7 > ^^^^ -+8 > ^^^ -+9 > ^^ -+10> ^ -+11> ^^^^^^^^^ -+12> ^^^ -+13> ^^^^ -+14> ^^^ -+15> ^^ -+16> ^ -+17> ^^^^^^^ -+18> ^^ -+19> ^ - 1-> - > - > - 2 >export - 3 > - 4 > var --5 > _𐊧 --6 > = --7 > new --8 > Foo --9 > () --10> . --11> \u{102A7} --12> + --13> new --14> Foo --15> () --16> . --17> methodA --18> () --19> ; +@@= skipped -71, +71 lines =@@ + 17> methodA + 18> () + 19> ; -1->Emitted(15, 1) Source(22, 1) + SourceIndex(0) -2 >Emitted(15, 7) Source(22, 7) + SourceIndex(0) -3 >Emitted(15, 8) Source(22, 8) + SourceIndex(0) @@ -271,52 +175,29 @@ -17>Emitted(15, 57) Source(22, 57) + SourceIndex(0) -18>Emitted(15, 59) Source(22, 59) + SourceIndex(0) -19>Emitted(15, 60) Source(22, 60) + SourceIndex(0) -+5 > _π -+6 > Š§ -+7 > = n -+8 > ew -+9 > Fo -+10> o -+11> ().\u{102 -+12> A7} -+13> + n -+14> ew -+15> Fo -+16> o -+17> ().meth -+18> od -+19> A +1->Emitted(16, 1) Source(22, 1) + SourceIndex(0) +2 >Emitted(16, 7) Source(22, 7) + SourceIndex(0) +3 >Emitted(16, 8) Source(22, 8) + SourceIndex(0) +4 >Emitted(16, 12) Source(22, 12) + SourceIndex(0) -+5 >Emitted(16, 17) Source(22, 14) + SourceIndex(0) -+6 >Emitted(16, 20) Source(22, 17) + SourceIndex(0) -+7 >Emitted(16, 24) Source(22, 21) + SourceIndex(0) -+8 >Emitted(16, 27) Source(22, 24) + SourceIndex(0) -+9 >Emitted(16, 29) Source(22, 26) + SourceIndex(0) -+10>Emitted(16, 30) Source(22, 27) + SourceIndex(0) -+11>Emitted(16, 39) Source(22, 36) + SourceIndex(0) -+12>Emitted(16, 42) Source(22, 39) + SourceIndex(0) -+13>Emitted(16, 46) Source(22, 43) + SourceIndex(0) -+14>Emitted(16, 49) Source(22, 46) + SourceIndex(0) -+15>Emitted(16, 51) Source(22, 48) + SourceIndex(0) -+16>Emitted(16, 52) Source(22, 49) + SourceIndex(0) -+17>Emitted(16, 59) Source(22, 56) + SourceIndex(0) -+18>Emitted(16, 61) Source(22, 58) + SourceIndex(0) -+19>Emitted(16, 62) Source(22, 59) + SourceIndex(0) ++5 >Emitted(16, 15) Source(22, 15) + SourceIndex(0) ++6 >Emitted(16, 18) Source(22, 18) + SourceIndex(0) ++7 >Emitted(16, 22) Source(22, 22) + SourceIndex(0) ++8 >Emitted(16, 25) Source(22, 25) + SourceIndex(0) ++9 >Emitted(16, 27) Source(22, 27) + SourceIndex(0) ++10>Emitted(16, 28) Source(22, 28) + SourceIndex(0) ++11>Emitted(16, 37) Source(22, 37) + SourceIndex(0) ++12>Emitted(16, 40) Source(22, 40) + SourceIndex(0) ++13>Emitted(16, 44) Source(22, 44) + SourceIndex(0) ++14>Emitted(16, 47) Source(22, 47) + SourceIndex(0) ++15>Emitted(16, 49) Source(22, 49) + SourceIndex(0) ++16>Emitted(16, 50) Source(22, 50) + SourceIndex(0) ++17>Emitted(16, 57) Source(22, 57) + SourceIndex(0) ++18>Emitted(16, 59) Source(22, 59) + SourceIndex(0) ++19>Emitted(16, 60) Source(22, 60) + SourceIndex(0) --- >>>_\u{102A7} += "!"; 1 > -@@= skipped -133, +136 lines =@@ - 4 > ^^^ - 5 > ^ - 6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> --1 > -+1 >(); - > - > - 2 >_\u{102A7} +@@= skipped -34, +34 lines =@@ 3 > += 4 > "!" 5 > ; diff --git a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).symbols b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).symbols index dfd78ea13e..2a5919ded6 100644 --- a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).symbols +++ b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).symbols @@ -59,6 +59,6 @@ _\u{102A7} += "!"; import { _𐊧 as \uD800\uDEA7 } from "./extendedEscapesForAstralsInVarsAndClasses.js"; >_𐊧 : Symbol((Missing), Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 21, 10)) > : Symbol((Missing), Decl(astralAsSurrogatePair.ts, 0, 8)) ->uD800 : Symbol(uD800, Decl(astralAsSurrogatePair.ts, 0, 16)) ->uDEA7 : Symbol(uDEA7, Decl(astralAsSurrogatePair.ts, 0, 22)) +>uD800 : Symbol(uD800, Decl(astralAsSurrogatePair.ts, 0, 17)) +>uDEA7 : Symbol(uDEA7, Decl(astralAsSurrogatePair.ts, 0, 23)) diff --git a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).symbols.diff b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).symbols.diff deleted file mode 100644 index 6d60f8da97..0000000000 --- a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInNames02(target=es2015).symbols.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.unicodeEscapesInNames02(target=es2015).symbols -+++ new.unicodeEscapesInNames02(target=es2015).symbols -@@= skipped -58, +58 lines =@@ - import { _𐊧 as \uD800\uDEA7 } from "./extendedEscapesForAstralsInVarsAndClasses.js"; - >_𐊧 : Symbol((Missing), Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 21, 10)) - > : Symbol((Missing), Decl(astralAsSurrogatePair.ts, 0, 8)) -->uD800 : Symbol(uD800, Decl(astralAsSurrogatePair.ts, 0, 17)) -->uDEA7 : Symbol(uDEA7, Decl(astralAsSurrogatePair.ts, 0, 23)) -+>uD800 : Symbol(uD800, Decl(astralAsSurrogatePair.ts, 0, 16)) -+>uDEA7 : Symbol(uDEA7, Decl(astralAsSurrogatePair.ts, 0, 22)) From e095fbb0bb2649402adc98f627a08f54dc69a8b2 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 23 Feb 2026 10:37:26 -0800 Subject: [PATCH 2/9] Fix formatting it seems --- internal/format/indent.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/internal/format/indent.go b/internal/format/indent.go index 4d074e8b0b..9020a56ecc 100644 --- a/internal/format/indent.go +++ b/internal/format/indent.go @@ -217,14 +217,11 @@ func FindFirstNonWhitespaceColumn(startPos int, endPos int, sourceFile *ast.Sour * value of 'column' for '$' is 6 (assuming that tab size is 4) */ func findFirstNonWhitespaceCharacterAndColumn(startPos int, endPos int, sourceFile *ast.SourceFile, options *lsutil.FormatCodeSettings) (character int, column int) { - character = 0 column = 0 text := sourceFile.Text() - for pos := startPos; pos < endPos; pos++ { + pos := startPos + for pos < endPos { ch, size := utf8.DecodeRuneInString(text[pos:]) - if size == 0 && ch == utf8.RuneError { - continue // multibyte character - TODO: recognize non-tab multicolumn characters? ideographic space? - } if !stringutil.IsWhiteSpaceSingleLine(ch) { break } @@ -235,9 +232,9 @@ func findFirstNonWhitespaceCharacterAndColumn(startPos int, endPos int, sourceFi column++ } - character++ + pos += size } - return character, column + return pos - startPos, column } func childStartsOnTheSameLineWithElseInIfStatement(parent *ast.Node, child *ast.Node, childStartLine int, sourceFile *ast.SourceFile) bool { From 110e3287db4da9c38cf747b44bf2778b0e423af7 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 23 Feb 2026 10:54:53 -0800 Subject: [PATCH 3/9] annoying copilot --- internal/printer/textwriter.go | 4 ++-- internal/printer/utilities.go | 3 +-- internal/scanner/scanner.go | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/internal/printer/textwriter.go b/internal/printer/textwriter.go index 8b532d9222..70851c89be 100644 --- a/internal/printer/textwriter.go +++ b/internal/printer/textwriter.go @@ -31,8 +31,8 @@ func (w *textWriter) DecreaseIndent() { w.indent-- } -// GetColumn returns the column position measured in UTF-16 code units, -// matching TypeScript's native encoding for source map compatibility. +// GetColumn returns the column position measured in UTF-16 code units +// for source map compatibility. func (w *textWriter) GetColumn() int { if w.lineStart { return w.indent * w.indentSize diff --git a/internal/printer/utilities.go b/internal/printer/utilities.go index b33cfd2182..b68f74e00a 100644 --- a/internal/printer/utilities.go +++ b/internal/printer/utilities.go @@ -896,8 +896,7 @@ func calculateIndent(text string, pos int, end int) int { // position and the new position needs to be scanned for UTF-16 code unit counts, // turning what would be O(nΒ²) into O(n) for long lines. // -// Character offsets are measured in UTF-16 code units, matching TypeScript's -// native encoding and the source map specification. +// Character offsets are measured in UTF-16 code units per the source map specification. type lineCharacterCache struct { lineMap []core.TextPos text string diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 5b80e8a69e..fc4cd51a09 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -2463,7 +2463,6 @@ func GetECMALineOfPosition(sourceFile ast.SourceFileLike, pos int) int { // GetECMALineAndCharacterOfPosition returns the 0-based line number and the // UTF-16 code unit offset from the start of that line for the given byte position. // Uses ECMAScript line separators (LF, CR, CRLF, LS, PS). -// This matches TypeScript's native getLineAndCharacterOfPosition. func GetECMALineAndCharacterOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, character int) { lineMap := GetECMALineStarts(sourceFile) line = ComputeLineOfPosition(lineMap, pos) @@ -2531,8 +2530,7 @@ func ComputePositionOfLineAndByteOffset(lineStarts []core.TextPos, line int, byt } // ComputePositionOfLineAndCharacterEx converts a line and UTF-16 character offset -// back to a byte position. The character parameter is measured in UTF-16 code units, -// matching the encoding used by TypeScript and source maps. +// back to a byte position. The character parameter is measured in UTF-16 code units. // When text is provided, it scans from the line start to correctly handle multi-byte characters. // When text is nil, character is treated as a byte offset (legacy behavior). // When allowEdits is true, out-of-range values are clamped instead of panicking. From a29d7c0821efb41b89fc1041e36ee2901a8b06cd Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 23 Feb 2026 11:20:23 -0800 Subject: [PATCH 4/9] more dedupe --- internal/scanner/scanner.go | 50 +++++-------------- internal/sourcemap/source_mapper.go | 4 +- .../harnessutil/sourcemap_recorder.go | 2 +- 3 files changed, 16 insertions(+), 40 deletions(-) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index fc4cd51a09..9c7f58c2fd 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -2497,20 +2497,7 @@ func GetECMAEndLinePosition(sourceFile *ast.SourceFile, line int) int { // Uses ECMAScript line separators. func GetECMAPositionOfLineAndCharacter(sourceFile ast.SourceFileLike, line int, character int) int { lineStarts := GetECMALineStarts(sourceFile) - lineStart := int(lineStarts[line]) - if character == 0 { - return lineStart - } - // Scan from line start counting UTF-16 code units to find the byte position. - text := sourceFile.Text() - utf16Count := 0 - for i, r := range text[lineStart:] { - if utf16Count >= character { - return lineStart + i - } - utf16Count += utf16.RuneLen(r) - } - return len(text) + return ComputePositionOfLineAndCharacterEx(lineStarts, line, character, sourceFile.Text(), false) } // GetECMAPositionOfLineAndByteOffset converts a 0-based line number and byte offset @@ -2531,10 +2518,9 @@ func ComputePositionOfLineAndByteOffset(lineStarts []core.TextPos, line int, byt // ComputePositionOfLineAndCharacterEx converts a line and UTF-16 character offset // back to a byte position. The character parameter is measured in UTF-16 code units. -// When text is provided, it scans from the line start to correctly handle multi-byte characters. -// When text is nil, character is treated as a byte offset (legacy behavior). +// It scans from the line start to correctly handle multi-byte characters. // When allowEdits is true, out-of-range values are clamped instead of panicking. -func ComputePositionOfLineAndCharacterEx(lineStarts []core.TextPos, line int, character int, text *string, allowEdits bool) int { +func ComputePositionOfLineAndCharacterEx(lineStarts []core.TextPos, line int, character int, text string, allowEdits bool) int { if line < 0 || line >= len(lineStarts) { if allowEdits { // Clamp line to nearest allowable value @@ -2550,9 +2536,9 @@ func ComputePositionOfLineAndCharacterEx(lineStarts []core.TextPos, line int, ch lineStart := int(lineStarts[line]) - if text != nil && character > 0 { + if character > 0 { // UTF-16 character offset: scan from line start counting UTF-16 code units. - lineEnd := len(*text) + lineEnd := len(text) if line+1 < len(lineStarts) { lineEnd = int(lineStarts[line+1]) } @@ -2562,38 +2548,28 @@ func ComputePositionOfLineAndCharacterEx(lineStarts []core.TextPos, line int, ch if utf16Count >= character { break } - r, size := utf8.DecodeRuneInString((*text)[pos:]) + r, size := utf8.DecodeRuneInString(text[pos:]) utf16Count += utf16.RuneLen(r) pos += size } if allowEdits { - if pos > len(*text) { - return len(*text) + if pos > len(text) { + return len(text) } } return pos } - // No text or character is 0: treat character as byte offset (simple addition). - res := lineStart + character + // Character is 0: line start position. + res := lineStart if allowEdits { - // Clamp to nearest allowable values to allow the underlying to be edited without crashing (accuracy is lost, instead) - // TODO: Somehow track edits between file as it was during the creation of sourcemap we have and the current file and - // apply them to the computed position to improve accuracy - if line+1 < len(lineStarts) && res > int(lineStarts[line+1]) { - return int(lineStarts[line+1]) - } - if text != nil && res > len(*text) { - return len(*text) + if res > len(text) { + return len(text) } return res } - if line < len(lineStarts)-1 && res >= int(lineStarts[line+1]) { - panic("Computed position is beyond that of the following line.") - } else if text != nil { - debug.Assert(res <= len(*text)) // Allow single character overflow for trailing newline - } + debug.Assert(res <= len(text)) // Allow single character overflow for trailing newline return res } diff --git a/internal/sourcemap/source_mapper.go b/internal/sourcemap/source_mapper.go index 0ce1c6422e..6947653049 100644 --- a/internal/sourcemap/source_mapper.go +++ b/internal/sourcemap/source_mapper.go @@ -82,7 +82,7 @@ func createDocumentPositionMapper(host Host, sourceMap *RawSourceMap, mapPath st lineInfo.lineStarts, mapping.GeneratedLine, mapping.GeneratedCharacter, - &lineInfo.text, + lineInfo.text, true, /*allowEdits*/ ) } @@ -95,7 +95,7 @@ func createDocumentPositionMapper(host Host, sourceMap *RawSourceMap, mapPath st lineInfo.lineStarts, mapping.SourceLine, mapping.SourceCharacter, - &lineInfo.text, + lineInfo.text, true, /*allowEdits*/ ) sourcePosition = pos diff --git a/internal/testutil/harnessutil/sourcemap_recorder.go b/internal/testutil/harnessutil/sourcemap_recorder.go index a83f106aec..eab88f5e88 100644 --- a/internal/testutil/harnessutil/sourcemap_recorder.go +++ b/internal/testutil/harnessutil/sourcemap_recorder.go @@ -295,7 +295,7 @@ func (sw *recordedSpanWriter) writeSourceMapSourceText(currentSpan *sourceMapSpa sw.w.tsLineMap, currentSpan.sourceMapSpan.SourceLine, currentSpan.sourceMapSpan.SourceCharacter, - &sw.w.tsCode, + sw.w.tsCode, true, /*allowEdits*/ ) var sourceText string From b9ee006a0950f8a4263a045392c68f5cda14134f Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 23 Feb 2026 11:27:19 -0800 Subject: [PATCH 5/9] Rename functions --- internal/astnav/tokens_test.go | 8 ++++---- internal/compiler/emit_test.go | 2 +- internal/core/core.go | 6 +++--- internal/diagnosticwriter/diagnosticwriter.go | 8 ++++---- internal/scanner/scanner.go | 16 ++++++++-------- internal/sourcemap/source_mapper.go | 4 ++-- .../testutil/harnessutil/sourcemap_recorder.go | 2 +- .../testutil/tsbaseline/type_symbol_baseline.go | 2 +- internal/transformers/jsxtransforms/jsx.go | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/internal/astnav/tokens_test.go b/internal/astnav/tokens_test.go index 671f92280b..285e69f9b0 100644 --- a/internal/astnav/tokens_test.go +++ b/internal/astnav/tokens_test.go @@ -300,10 +300,10 @@ func writeRangeDiff(output *strings.Builder, file *ast.SourceFile, diff tokenDif goTokenPos = diff.goToken.Pos goTokenEnd = diff.goToken.End } - tsStartLine, _ := core.PositionToLineAndCharacter(tsTokenPos, lines) - tsEndLine, _ := core.PositionToLineAndCharacter(tsTokenEnd, lines) - goStartLine, _ := core.PositionToLineAndCharacter(goTokenPos, lines) - goEndLine, _ := core.PositionToLineAndCharacter(goTokenEnd, lines) + tsStartLine, _ := core.PositionToLineAndByteOffset(tsTokenPos, lines) + tsEndLine, _ := core.PositionToLineAndByteOffset(tsTokenEnd, lines) + goStartLine, _ := core.PositionToLineAndByteOffset(goTokenPos, lines) + goEndLine, _ := core.PositionToLineAndByteOffset(goTokenEnd, lines) contextLines := 2 startLine := min(tsStartLine, goStartLine) diff --git a/internal/compiler/emit_test.go b/internal/compiler/emit_test.go index e0682e91fb..7a97c03a8e 100644 --- a/internal/compiler/emit_test.go +++ b/internal/compiler/emit_test.go @@ -16,7 +16,7 @@ import ( // generateLongLineTS generates TypeScript source code that produces a single very long line. // This simulates generated code (e.g., from code generators) that has no line breaks, // which triggers O(nΒ²) behavior in source map generation due to -// GetECMALineAndCharacterOfPosition scanning from line start for each position. +// GetECMALineAndUTF16CharacterOfPosition scanning from line start for each position. func generateLongLineTS(numProperties int) string { // Build a large object literal all on one line, with no line breaks. var b strings.Builder diff --git a/internal/core/core.go b/internal/core/core.go index 2fe7bcffaf..59414e1fbf 100644 --- a/internal/core/core.go +++ b/internal/core/core.go @@ -441,10 +441,10 @@ func ComputeECMALineStartsSeq(text string) iter.Seq[TextPos] { } } -// PositionToLineAndCharacter returns the 0-based line and byte offset from the +// PositionToLineAndByteOffset returns the 0-based line and byte offset from the // start of that line for the given byte position, using the provided line starts. -// The character is a raw UTF-8 byte offset from the line start, not a UTF-16 code unit count. -func PositionToLineAndCharacter(position int, lineStarts []TextPos) (line int, character int) { +// The byte offset is a raw UTF-8 byte offset from the line start, not a UTF-16 code unit count. +func PositionToLineAndByteOffset(position int, lineStarts []TextPos) (line int, byteOffset int) { line = max(sort.Search(len(lineStarts), func(i int) bool { return int(lineStarts[i]) > position })-1, 0) diff --git a/internal/diagnosticwriter/diagnosticwriter.go b/internal/diagnosticwriter/diagnosticwriter.go index 66c4d78756..ee1a971145 100644 --- a/internal/diagnosticwriter/diagnosticwriter.go +++ b/internal/diagnosticwriter/diagnosticwriter.go @@ -167,8 +167,8 @@ func FormatDiagnosticWithColorAndContext(output io.Writer, diagnostic Diagnostic } func writeCodeSnippet(writer io.Writer, sourceFile FileLike, start int, length int, squiggleColor string, indent string, formatOpts *FormattingOptions) { - firstLine, firstLineChar := scanner.GetECMALineAndCharacterOfPosition(sourceFile, start) - lastLine, lastLineChar := scanner.GetECMALineAndCharacterOfPosition(sourceFile, start+length) + firstLine, firstLineChar := scanner.GetECMALineAndUTF16CharacterOfPosition(sourceFile, start) + lastLine, lastLineChar := scanner.GetECMALineAndUTF16CharacterOfPosition(sourceFile, start+length) if length == 0 { lastLineChar++ // When length is zero, squiggle the character right after the start position. } @@ -303,7 +303,7 @@ func writeWithStyleAndReset(output io.Writer, text string, formatStyle string) { } func WriteLocation(output io.Writer, file FileLike, pos int, formatOpts *FormattingOptions, writeWithStyleAndReset FormattedWriter) { - firstLine, firstChar := scanner.GetECMALineAndCharacterOfPosition(file, pos) + firstLine, firstChar := scanner.GetECMALineAndUTF16CharacterOfPosition(file, pos) var relativeFileName string if formatOpts != nil { relativeFileName = tspath.ConvertToRelativePath(file.FileName(), formatOpts.ComparePathsOptions) @@ -465,7 +465,7 @@ func WriteFormatDiagnostics(output io.Writer, diagnostics []Diagnostic, formatOp func WriteFormatDiagnostic(output io.Writer, diagnostic Diagnostic, formatOpts *FormattingOptions) { if diagnostic.File() != nil { - line, character := scanner.GetECMALineAndCharacterOfPosition(diagnostic.File(), diagnostic.Pos()) + line, character := scanner.GetECMALineAndUTF16CharacterOfPosition(diagnostic.File(), diagnostic.Pos()) fileName := diagnostic.File().FileName() relativeFileName := tspath.ConvertToRelativePath(fileName, formatOpts.ComparePathsOptions) fmt.Fprintf(output, "%s(%d,%d): ", relativeFileName, line+1, character+1) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 9c7f58c2fd..ce4ae9fc82 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -2460,10 +2460,10 @@ func GetECMALineOfPosition(sourceFile ast.SourceFileLike, pos int) int { return ComputeLineOfPosition(lineMap, pos) } -// GetECMALineAndCharacterOfPosition returns the 0-based line number and the +// GetECMALineAndUTF16CharacterOfPosition returns the 0-based line number and the // UTF-16 code unit offset from the start of that line for the given byte position. // Uses ECMAScript line separators (LF, CR, CRLF, LS, PS). -func GetECMALineAndCharacterOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, character int) { +func GetECMALineAndUTF16CharacterOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, character int) { lineMap := GetECMALineStarts(sourceFile) line = ComputeLineOfPosition(lineMap, pos) character = core.UTF16Len(sourceFile.Text()[lineMap[line]:pos]) @@ -2473,7 +2473,7 @@ func GetECMALineAndCharacterOfPosition(sourceFile ast.SourceFileLike, pos int) ( // GetECMALineAndByteOffsetOfPosition returns the 0-based line number and the // raw UTF-8 byte offset from the start of that line for the given byte position. // Uses ECMAScript line separators (LF, CR, CRLF, LS, PS). -// Unlike GetECMALineAndCharacterOfPosition, the offset is in bytes, not UTF-16 code units. +// Unlike GetECMALineAndUTF16CharacterOfPosition, the offset is in bytes, not UTF-16 code units. func GetECMALineAndByteOffsetOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, byteOffset int) { lineMap := GetECMALineStarts(sourceFile) line = ComputeLineOfPosition(lineMap, pos) @@ -2492,12 +2492,12 @@ func GetECMAEndLinePosition(sourceFile *ast.SourceFile, line int) int { } } -// GetECMAPositionOfLineAndCharacter converts a 0-based line number and UTF-16 +// GetECMAPositionOfLineAndUTF16Character converts a 0-based line number and UTF-16 // code unit character offset back to an absolute byte position in the source text. // Uses ECMAScript line separators. -func GetECMAPositionOfLineAndCharacter(sourceFile ast.SourceFileLike, line int, character int) int { +func GetECMAPositionOfLineAndUTF16Character(sourceFile ast.SourceFileLike, line int, character int) int { lineStarts := GetECMALineStarts(sourceFile) - return ComputePositionOfLineAndCharacterEx(lineStarts, line, character, sourceFile.Text(), false) + return ComputePositionOfLineAndUTF16Character(lineStarts, line, character, sourceFile.Text(), false) } // GetECMAPositionOfLineAndByteOffset converts a 0-based line number and byte offset @@ -2516,11 +2516,11 @@ func ComputePositionOfLineAndByteOffset(lineStarts []core.TextPos, line int, byt return int(lineStarts[line]) + byteOffset } -// ComputePositionOfLineAndCharacterEx converts a line and UTF-16 character offset +// ComputePositionOfLineAndUTF16Character converts a line and UTF-16 character offset // back to a byte position. The character parameter is measured in UTF-16 code units. // It scans from the line start to correctly handle multi-byte characters. // When allowEdits is true, out-of-range values are clamped instead of panicking. -func ComputePositionOfLineAndCharacterEx(lineStarts []core.TextPos, line int, character int, text string, allowEdits bool) int { +func ComputePositionOfLineAndUTF16Character(lineStarts []core.TextPos, line int, character int, text string, allowEdits bool) int { if line < 0 || line >= len(lineStarts) { if allowEdits { // Clamp line to nearest allowable value diff --git a/internal/sourcemap/source_mapper.go b/internal/sourcemap/source_mapper.go index 6947653049..061cf277a7 100644 --- a/internal/sourcemap/source_mapper.go +++ b/internal/sourcemap/source_mapper.go @@ -78,7 +78,7 @@ func createDocumentPositionMapper(host Host, sourceMap *RawSourceMap, mapPath st generatedPosition := -1 lineInfo := host.GetECMALineInfo(generatedAbsoluteFilePath) if lineInfo != nil { - generatedPosition = scanner.ComputePositionOfLineAndCharacterEx( + generatedPosition = scanner.ComputePositionOfLineAndUTF16Character( lineInfo.lineStarts, mapping.GeneratedLine, mapping.GeneratedCharacter, @@ -91,7 +91,7 @@ func createDocumentPositionMapper(host Host, sourceMap *RawSourceMap, mapPath st if mapping.IsSourceMapping() { lineInfo := host.GetECMALineInfo(sourceFileAbsolutePaths[mapping.SourceIndex]) if lineInfo != nil { - pos := scanner.ComputePositionOfLineAndCharacterEx( + pos := scanner.ComputePositionOfLineAndUTF16Character( lineInfo.lineStarts, mapping.SourceLine, mapping.SourceCharacter, diff --git a/internal/testutil/harnessutil/sourcemap_recorder.go b/internal/testutil/harnessutil/sourcemap_recorder.go index eab88f5e88..2550e4328f 100644 --- a/internal/testutil/harnessutil/sourcemap_recorder.go +++ b/internal/testutil/harnessutil/sourcemap_recorder.go @@ -291,7 +291,7 @@ func (sw *recordedSpanWriter) writeSourceMapMarkerEx(currentSpan *sourceMapSpanW func (sw *recordedSpanWriter) writeSourceMapSourceText(currentSpan *sourceMapSpanWithDecodeErrors, index int) { // Convert UTF-16 character offset from the source map to a byte position. - sourcePos := scanner.ComputePositionOfLineAndCharacterEx( + sourcePos := scanner.ComputePositionOfLineAndUTF16Character( sw.w.tsLineMap, currentSpan.sourceMapSpan.SourceLine, currentSpan.sourceMapSpan.SourceCharacter, diff --git a/internal/testutil/tsbaseline/type_symbol_baseline.go b/internal/testutil/tsbaseline/type_symbol_baseline.go index e86884ac3e..3521bd5442 100644 --- a/internal/testutil/tsbaseline/type_symbol_baseline.go +++ b/internal/testutil/tsbaseline/type_symbol_baseline.go @@ -434,7 +434,7 @@ func (walker *typeWriterWalker) writeTypeOrSymbol(node *ast.Node, isSymbolWalk b } declSourceFile := ast.GetSourceFileOfNode(declaration) - declLine, declChar := scanner.GetECMALineAndCharacterOfPosition(declSourceFile, declaration.Pos()) + declLine, declChar := scanner.GetECMALineAndUTF16CharacterOfPosition(declSourceFile, declaration.Pos()) fileName := tspath.GetBaseFileName(declSourceFile.FileName()) symbolString.WriteString("Decl(") symbolString.WriteString(fileName) diff --git a/internal/transformers/jsxtransforms/jsx.go b/internal/transformers/jsxtransforms/jsx.go index 371bac5e31..88f77726c8 100644 --- a/internal/transformers/jsxtransforms/jsx.go +++ b/internal/transformers/jsxtransforms/jsx.go @@ -590,7 +590,7 @@ func (tx *JSXTransformer) visitJsxOpeningLikeElementOrFragmentJSX( args = append(args, tx.Factory().NewFalseExpression()) } // __source development flag - line, col := scanner.GetECMALineAndCharacterOfPosition(originalFile.AsSourceFile(), location.Pos()) + line, col := scanner.GetECMALineAndUTF16CharacterOfPosition(originalFile.AsSourceFile(), location.Pos()) args = append(args, tx.Factory().NewObjectLiteralExpression(tx.Factory().NewNodeList([]*ast.Node{ tx.Factory().NewPropertyAssignment(nil, tx.Factory().NewIdentifier("fileName"), nil, nil, tx.getCurrentFileNameExpression()), tx.Factory().NewPropertyAssignment(nil, tx.Factory().NewIdentifier("lineNumber"), nil, nil, tx.Factory().NewNumericLiteral(strconv.FormatInt(int64(line+1), 10), ast.TokenFlagsNone)), From b15a5e35422a3ac3420fba0f1f2e36f8d8da0105 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 23 Feb 2026 11:54:53 -0800 Subject: [PATCH 6/9] Introduce UTF16Offset --- internal/checker/printer.go | 2 +- internal/core/core.go | 9 +++-- internal/diagnosticwriter/diagnosticwriter.go | 12 +++--- internal/printer/changetrackerwriter.go | 12 +++--- internal/printer/emittextwriter.go | 7 +++- internal/printer/singlelinestringwriter.go | 3 +- internal/printer/textwriter.go | 4 +- internal/printer/utilities.go | 4 +- internal/scanner/scanner.go | 10 ++--- internal/sourcemap/decoder.go | 23 +++++------ internal/sourcemap/generator.go | 38 ++++++++++--------- .../harnessutil/sourcemap_recorder.go | 6 +-- .../tsbaseline/type_symbol_baseline.go | 2 +- internal/transformers/jsxtransforms/jsx.go | 2 +- 14 files changed, 72 insertions(+), 62 deletions(-) diff --git a/internal/checker/printer.go b/internal/checker/printer.go index b6a2408f74..715771f8e5 100644 --- a/internal/checker/printer.go +++ b/internal/checker/printer.go @@ -49,7 +49,7 @@ func (s *semicolonRemoverWriter) DecreaseIndent() { s.inner.DecreaseIndent() } -func (s *semicolonRemoverWriter) GetColumn() int { +func (s *semicolonRemoverWriter) GetColumn() core.UTF16Offset { return s.inner.GetColumn() } diff --git a/internal/core/core.go b/internal/core/core.go index 59414e1fbf..ae4d42db55 100644 --- a/internal/core/core.go +++ b/internal/core/core.go @@ -451,12 +451,15 @@ func PositionToLineAndByteOffset(position int, lineStarts []TextPos) (line int, return line, position - int(lineStarts[line]) } +// UTF16Offset represents a character offset measured in UTF-16 code units. +type UTF16Offset int + // UTF16Len returns the number of UTF-16 code units needed to // represent the given UTF-8 encoded string. -func UTF16Len(s string) int { - n := 0 +func UTF16Len(s string) UTF16Offset { + n := UTF16Offset(0) for _, r := range s { - n += utf16.RuneLen(r) + n += UTF16Offset(utf16.RuneLen(r)) } return n } diff --git a/internal/diagnosticwriter/diagnosticwriter.go b/internal/diagnosticwriter/diagnosticwriter.go index ee1a971145..4c6aa0255f 100644 --- a/internal/diagnosticwriter/diagnosticwriter.go +++ b/internal/diagnosticwriter/diagnosticwriter.go @@ -229,18 +229,18 @@ func writeCodeSnippet(writer io.Writer, sourceFile FileLike, start int, length i // Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position. var lastCharForLine int if i == lastLine { - lastCharForLine = lastLineChar + lastCharForLine = int(lastLineChar) } else { lastCharForLine = len(lineContent) } // Fill with spaces until the first character, // then squiggle the remainder of the line. - fmt.Fprint(writer, strings.Repeat(" ", firstLineChar)) - fmt.Fprint(writer, strings.Repeat("~", lastCharForLine-firstLineChar)) + fmt.Fprint(writer, strings.Repeat(" ", int(firstLineChar))) + fmt.Fprint(writer, strings.Repeat("~", lastCharForLine-int(firstLineChar))) case lastLine: // Squiggle until the final character. - fmt.Fprint(writer, strings.Repeat("~", lastLineChar)) + fmt.Fprint(writer, strings.Repeat("~", int(lastLineChar))) default: // Squiggle the entire line. fmt.Fprint(writer, strings.Repeat("~", len(lineContent))) @@ -315,7 +315,7 @@ func WriteLocation(output io.Writer, file FileLike, pos int, formatOpts *Formatt fmt.Fprint(output, ":") writeWithStyleAndReset(output, strconv.Itoa(firstLine+1), foregroundColorEscapeYellow) fmt.Fprint(output, ":") - writeWithStyleAndReset(output, strconv.Itoa(firstChar+1), foregroundColorEscapeYellow) + writeWithStyleAndReset(output, strconv.Itoa(int(firstChar)+1), foregroundColorEscapeYellow) } // Some of these lived in watch.ts, but they're not specific to the watch API. @@ -468,7 +468,7 @@ func WriteFormatDiagnostic(output io.Writer, diagnostic Diagnostic, formatOpts * line, character := scanner.GetECMALineAndUTF16CharacterOfPosition(diagnostic.File(), diagnostic.Pos()) fileName := diagnostic.File().FileName() relativeFileName := tspath.ConvertToRelativePath(fileName, formatOpts.ComparePathsOptions) - fmt.Fprintf(output, "%s(%d,%d): ", relativeFileName, line+1, character+1) + fmt.Fprintf(output, "%s(%d,%d): ", relativeFileName, line+1, int(character)+1) } fmt.Fprintf(output, "%s TS%d: ", diagnostic.Category().Name(), diagnostic.Code()) diff --git a/internal/printer/changetrackerwriter.go b/internal/printer/changetrackerwriter.go index 720272c959..9e365030e2 100644 --- a/internal/printer/changetrackerwriter.go +++ b/internal/printer/changetrackerwriter.go @@ -224,12 +224,12 @@ func (ct *ChangeTrackerWriter) WriteLiteral(s string) { ct.textWriter.WriteLiteral(s) ct.setLastNonTriviaPosition(s, true) } -func (ct *ChangeTrackerWriter) GetTextPos() int { return ct.textWriter.GetTextPos() } -func (ct *ChangeTrackerWriter) GetLine() int { return ct.textWriter.GetLine() } -func (ct *ChangeTrackerWriter) GetColumn() int { return ct.textWriter.GetColumn() } -func (ct *ChangeTrackerWriter) GetIndent() int { return ct.textWriter.GetIndent() } -func (ct *ChangeTrackerWriter) IsAtStartOfLine() bool { return ct.textWriter.IsAtStartOfLine() } -func (ct *ChangeTrackerWriter) HasTrailingComment() bool { return ct.textWriter.HasTrailingComment() } +func (ct *ChangeTrackerWriter) GetTextPos() int { return ct.textWriter.GetTextPos() } +func (ct *ChangeTrackerWriter) GetLine() int { return ct.textWriter.GetLine() } +func (ct *ChangeTrackerWriter) GetColumn() core.UTF16Offset { return ct.textWriter.GetColumn() } +func (ct *ChangeTrackerWriter) GetIndent() int { return ct.textWriter.GetIndent() } +func (ct *ChangeTrackerWriter) IsAtStartOfLine() bool { return ct.textWriter.IsAtStartOfLine() } +func (ct *ChangeTrackerWriter) HasTrailingComment() bool { return ct.textWriter.HasTrailingComment() } func (ct *ChangeTrackerWriter) HasTrailingWhitespace() bool { return ct.textWriter.HasTrailingWhitespace() } diff --git a/internal/printer/emittextwriter.go b/internal/printer/emittextwriter.go index a66117bdb5..133328dbe2 100644 --- a/internal/printer/emittextwriter.go +++ b/internal/printer/emittextwriter.go @@ -1,6 +1,9 @@ package printer -import "github.com/microsoft/typescript-go/internal/ast" +import ( + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/core" +) // Externally opaque interface for printing text type EmitTextWriter interface { @@ -25,7 +28,7 @@ type EmitTextWriter interface { WriteLiteral(s string) GetTextPos() int GetLine() int - GetColumn() int + GetColumn() core.UTF16Offset GetIndent() int IsAtStartOfLine() bool HasTrailingComment() bool diff --git a/internal/printer/singlelinestringwriter.go b/internal/printer/singlelinestringwriter.go index 2b7241eec1..95bccea614 100644 --- a/internal/printer/singlelinestringwriter.go +++ b/internal/printer/singlelinestringwriter.go @@ -6,6 +6,7 @@ import ( "unicode/utf8" "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/stringutil" ) @@ -39,7 +40,7 @@ func (w singleLineStringWriter) DecreaseIndent() { // Do Nothing } -func (w singleLineStringWriter) GetColumn() int { +func (w singleLineStringWriter) GetColumn() core.UTF16Offset { return 0 } diff --git a/internal/printer/textwriter.go b/internal/printer/textwriter.go index 70851c89be..94c43a76be 100644 --- a/internal/printer/textwriter.go +++ b/internal/printer/textwriter.go @@ -33,9 +33,9 @@ func (w *textWriter) DecreaseIndent() { // GetColumn returns the column position measured in UTF-16 code units // for source map compatibility. -func (w *textWriter) GetColumn() int { +func (w *textWriter) GetColumn() core.UTF16Offset { if w.lineStart { - return w.indent * w.indentSize + return core.UTF16Offset(w.indent * w.indentSize) } // Count UTF-16 code units from the last line start. // For ASCII-only output (the common case), this equals the byte count. diff --git a/internal/printer/utilities.go b/internal/printer/utilities.go index b68f74e00a..94276552a7 100644 --- a/internal/printer/utilities.go +++ b/internal/printer/utilities.go @@ -902,7 +902,7 @@ type lineCharacterCache struct { text string cachedLine int cachedPos int - cachedChar int + cachedChar core.UTF16Offset hasCached bool } @@ -915,7 +915,7 @@ func newLineCharacterCache(source sourcemap.Source) *lineCharacterCache { // getLineAndCharacter returns the 0-based line number and UTF-16 code unit // offset from the start of that line for the given byte position. -func (c *lineCharacterCache) getLineAndCharacter(pos int) (line int, character int) { +func (c *lineCharacterCache) getLineAndCharacter(pos int) (line int, character core.UTF16Offset) { line = scanner.ComputeLineOfPosition(c.lineMap, pos) if c.hasCached && line == c.cachedLine && pos >= c.cachedPos { // Incremental: only count UTF-16 code units from the last cached position. diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index ce4ae9fc82..b71277b24e 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -2463,7 +2463,7 @@ func GetECMALineOfPosition(sourceFile ast.SourceFileLike, pos int) int { // GetECMALineAndUTF16CharacterOfPosition returns the 0-based line number and the // UTF-16 code unit offset from the start of that line for the given byte position. // Uses ECMAScript line separators (LF, CR, CRLF, LS, PS). -func GetECMALineAndUTF16CharacterOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, character int) { +func GetECMALineAndUTF16CharacterOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, character core.UTF16Offset) { lineMap := GetECMALineStarts(sourceFile) line = ComputeLineOfPosition(lineMap, pos) character = core.UTF16Len(sourceFile.Text()[lineMap[line]:pos]) @@ -2495,7 +2495,7 @@ func GetECMAEndLinePosition(sourceFile *ast.SourceFile, line int) int { // GetECMAPositionOfLineAndUTF16Character converts a 0-based line number and UTF-16 // code unit character offset back to an absolute byte position in the source text. // Uses ECMAScript line separators. -func GetECMAPositionOfLineAndUTF16Character(sourceFile ast.SourceFileLike, line int, character int) int { +func GetECMAPositionOfLineAndUTF16Character(sourceFile ast.SourceFileLike, line int, character core.UTF16Offset) int { lineStarts := GetECMALineStarts(sourceFile) return ComputePositionOfLineAndUTF16Character(lineStarts, line, character, sourceFile.Text(), false) } @@ -2520,7 +2520,7 @@ func ComputePositionOfLineAndByteOffset(lineStarts []core.TextPos, line int, byt // back to a byte position. The character parameter is measured in UTF-16 code units. // It scans from the line start to correctly handle multi-byte characters. // When allowEdits is true, out-of-range values are clamped instead of panicking. -func ComputePositionOfLineAndUTF16Character(lineStarts []core.TextPos, line int, character int, text string, allowEdits bool) int { +func ComputePositionOfLineAndUTF16Character(lineStarts []core.TextPos, line int, character core.UTF16Offset, text string, allowEdits bool) int { if line < 0 || line >= len(lineStarts) { if allowEdits { // Clamp line to nearest allowable value @@ -2542,14 +2542,14 @@ func ComputePositionOfLineAndUTF16Character(lineStarts []core.TextPos, line int, if line+1 < len(lineStarts) { lineEnd = int(lineStarts[line+1]) } - utf16Count := 0 + utf16Count := core.UTF16Offset(0) pos := lineStart for pos < lineEnd { if utf16Count >= character { break } r, size := utf8.DecodeRuneInString(text[pos:]) - utf16Count += utf16.RuneLen(r) + utf16Count += core.UTF16Offset(utf16.RuneLen(r)) pos += size } if allowEdits { diff --git a/internal/sourcemap/decoder.go b/internal/sourcemap/decoder.go index 8d2af14f61..535ba2663d 100644 --- a/internal/sourcemap/decoder.go +++ b/internal/sourcemap/decoder.go @@ -9,10 +9,10 @@ import ( type Mapping struct { GeneratedLine int - GeneratedCharacter int + GeneratedCharacter core.UTF16Offset SourceIndex SourceIndex SourceLine int - SourceCharacter int + SourceCharacter core.UTF16Offset NameIndex NameIndex } @@ -28,13 +28,14 @@ func (m *Mapping) Equals(other *Mapping) bool { func (m *Mapping) IsSourceMapping() bool { return m.SourceIndex != MissingSource && m.SourceLine != MissingLineOrColumn && - m.SourceCharacter != MissingLineOrColumn + m.SourceCharacter != MissingUTF16Column } const ( - MissingSource SourceIndex = -1 - MissingName NameIndex = -1 - MissingLineOrColumn int = -1 + MissingSource SourceIndex = -1 + MissingName NameIndex = -1 + MissingLineOrColumn int = -1 + MissingUTF16Column core.UTF16Offset = -1 ) type MappingsDecoder struct { @@ -42,10 +43,10 @@ type MappingsDecoder struct { done bool pos int generatedLine int - generatedCharacter int + generatedCharacter core.UTF16Offset sourceIndex SourceIndex sourceLine int - sourceCharacter int + sourceCharacter core.UTF16Offset nameIndex NameIndex error error mappingPool core.Pool[Mapping] @@ -100,7 +101,7 @@ func (d *MappingsDecoder) Next() (value *Mapping, done bool) { hasSource := false hasName := false - d.generatedCharacter += d.base64VLQFormatDecode() + d.generatedCharacter += core.UTF16Offset(d.base64VLQFormatDecode()) if d.hasReportedError() { return d.stopIterating() } @@ -133,7 +134,7 @@ func (d *MappingsDecoder) Next() (value *Mapping, done bool) { return d.setErrorAndStopIterating("Unsupported Format: No entries after sourceLine") } - d.sourceCharacter += d.base64VLQFormatDecode() + d.sourceCharacter += core.UTF16Offset(d.base64VLQFormatDecode()) if d.hasReportedError() { return d.stopIterating() } @@ -169,7 +170,7 @@ func (d *MappingsDecoder) captureMapping(hasSource bool, hasName bool) *Mapping mapping.GeneratedCharacter = d.generatedCharacter mapping.SourceIndex = core.IfElse(hasSource, d.sourceIndex, MissingSource) mapping.SourceLine = core.IfElse(hasSource, d.sourceLine, MissingLineOrColumn) - mapping.SourceCharacter = core.IfElse(hasSource, d.sourceCharacter, MissingLineOrColumn) + mapping.SourceCharacter = core.IfElse(hasSource, d.sourceCharacter, MissingUTF16Column) mapping.NameIndex = core.IfElse(hasName, d.nameIndex, MissingName) return mapping } diff --git a/internal/sourcemap/generator.go b/internal/sourcemap/generator.go index c73ca42090..4ac8bf5cb5 100644 --- a/internal/sourcemap/generator.go +++ b/internal/sourcemap/generator.go @@ -5,6 +5,7 @@ import ( "slices" "strings" + "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/tspath" ) @@ -15,9 +16,10 @@ type ( ) const ( - sourceIndexNotSet SourceIndex = -1 - nameIndexNotSet NameIndex = -1 - notSet int = -1 + sourceIndexNotSet SourceIndex = -1 + nameIndexNotSet NameIndex = -1 + notSet int = -1 + notSetUTF16 core.UTF16Offset = -1 ) type Generator struct { @@ -33,17 +35,17 @@ type Generator struct { nameToNameIndexMap map[string]NameIndex mappings strings.Builder lastGeneratedLine int - lastGeneratedCharacter int + lastGeneratedCharacter core.UTF16Offset lastSourceIndex SourceIndex lastSourceLine int - lastSourceCharacter int + lastSourceCharacter core.UTF16Offset lastNameIndex NameIndex hasLast bool pendingGeneratedLine int - pendingGeneratedCharacter int + pendingGeneratedCharacter core.UTF16Offset pendingSourceIndex SourceIndex pendingSourceLine int - pendingSourceCharacter int + pendingSourceCharacter core.UTF16Offset pendingNameIndex NameIndex hasPending bool hasPendingSource bool @@ -120,16 +122,16 @@ func (gen *Generator) AddName(name string) NameIndex { return nameIndex } -func (gen *Generator) isNewGeneratedPosition(generatedLine int, generatedCharacter int) bool { +func (gen *Generator) isNewGeneratedPosition(generatedLine int, generatedCharacter core.UTF16Offset) bool { return !gen.hasPending || gen.pendingGeneratedLine != generatedLine || gen.pendingGeneratedCharacter != generatedCharacter } -func (gen *Generator) isBacktrackingSourcePosition(sourceIndex SourceIndex, sourceLine int, sourceCharacter int) bool { +func (gen *Generator) isBacktrackingSourcePosition(sourceIndex SourceIndex, sourceLine int, sourceCharacter core.UTF16Offset) bool { return sourceIndex != sourceIndexNotSet && sourceLine != notSet && - sourceCharacter != notSet && + sourceCharacter != notSetUTF16 && gen.pendingSourceIndex == sourceIndex && (gen.pendingSourceLine > sourceLine || gen.pendingSourceLine == sourceLine && gen.pendingSourceCharacter > sourceCharacter) @@ -205,7 +207,7 @@ func (gen *Generator) commitPendingMapping() { } // 1. Relative generated character - gen.appendBase64VLQ(gen.pendingGeneratedCharacter - gen.lastGeneratedCharacter) + gen.appendBase64VLQ(int(gen.pendingGeneratedCharacter - gen.lastGeneratedCharacter)) gen.lastGeneratedCharacter = gen.pendingGeneratedCharacter if gen.hasPendingSource { @@ -218,7 +220,7 @@ func (gen *Generator) commitPendingMapping() { gen.lastSourceLine = gen.pendingSourceLine // 4. Relative source character - gen.appendBase64VLQ(gen.pendingSourceCharacter - gen.lastSourceCharacter) + gen.appendBase64VLQ(int(gen.pendingSourceCharacter - gen.lastSourceCharacter)) gen.lastSourceCharacter = gen.pendingSourceCharacter if gen.hasPendingName { @@ -231,7 +233,7 @@ func (gen *Generator) commitPendingMapping() { gen.hasLast = true } -func (gen *Generator) addMapping(generatedLine int, generatedCharacter int, sourceIndex SourceIndex, sourceLine int, sourceCharacter int, nameIndex NameIndex) { +func (gen *Generator) addMapping(generatedLine int, generatedCharacter core.UTF16Offset, sourceIndex SourceIndex, sourceLine int, sourceCharacter core.UTF16Offset, nameIndex NameIndex) { if gen.isNewGeneratedPosition(generatedLine, generatedCharacter) || gen.isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) { gen.commitPendingMapping() @@ -242,7 +244,7 @@ func (gen *Generator) addMapping(generatedLine int, generatedCharacter int, sour gen.hasPending = true } - if sourceIndex != sourceIndexNotSet && sourceLine != notSet && sourceCharacter != notSet { + if sourceIndex != sourceIndexNotSet && sourceLine != notSet && sourceCharacter != notSetUTF16 { gen.pendingSourceIndex = sourceIndex gen.pendingSourceLine = sourceLine gen.pendingSourceCharacter = sourceCharacter @@ -255,19 +257,19 @@ func (gen *Generator) addMapping(generatedLine int, generatedCharacter int, sour } // Adds a mapping without source information -func (gen *Generator) AddGeneratedMapping(generatedLine int, generatedCharacter int) error { +func (gen *Generator) AddGeneratedMapping(generatedLine int, generatedCharacter core.UTF16Offset) error { if generatedLine < gen.pendingGeneratedLine { return errors.New("generatedLine cannot backtrack") } if generatedCharacter < 0 { return errors.New("generatedCharacter cannot be negative") } - gen.addMapping(generatedLine, generatedCharacter, sourceIndexNotSet, notSet /*sourceLine*/, notSet /*sourceCharacter*/, nameIndexNotSet) + gen.addMapping(generatedLine, generatedCharacter, sourceIndexNotSet, notSet /*sourceLine*/, notSetUTF16 /*sourceCharacter*/, nameIndexNotSet) return nil } // Adds a mapping with source information -func (gen *Generator) AddSourceMapping(generatedLine int, generatedCharacter int, sourceIndex SourceIndex, sourceLine int, sourceCharacter int) error { +func (gen *Generator) AddSourceMapping(generatedLine int, generatedCharacter core.UTF16Offset, sourceIndex SourceIndex, sourceLine int, sourceCharacter core.UTF16Offset) error { if generatedLine < gen.pendingGeneratedLine { return errors.New("generatedLine cannot backtrack") } @@ -288,7 +290,7 @@ func (gen *Generator) AddSourceMapping(generatedLine int, generatedCharacter int } // Adds a mapping with source and name information -func (gen *Generator) AddNamedSourceMapping(generatedLine int, generatedCharacter int, sourceIndex SourceIndex, sourceLine int, sourceCharacter int, nameIndex NameIndex) error { +func (gen *Generator) AddNamedSourceMapping(generatedLine int, generatedCharacter core.UTF16Offset, sourceIndex SourceIndex, sourceLine int, sourceCharacter core.UTF16Offset, nameIndex NameIndex) error { if generatedLine < gen.pendingGeneratedLine { return errors.New("generatedLine cannot backtrack") } diff --git a/internal/testutil/harnessutil/sourcemap_recorder.go b/internal/testutil/harnessutil/sourcemap_recorder.go index 2550e4328f..581ded57fa 100644 --- a/internal/testutil/harnessutil/sourcemap_recorder.go +++ b/internal/testutil/harnessutil/sourcemap_recorder.go @@ -166,7 +166,7 @@ func (w *sourceMapSpanWriter) recordSourceMapSpan(sourceMapSpan *sourcemap.Mappi func (w *sourceMapSpanWriter) recordNewSourceFileSpan(sourceMapSpan *sourcemap.Mapping, newSourceFileCode string) { continuesLine := false - if len(w.spansOnSingleLine) > 0 && w.spansOnSingleLine[0].sourceMapSpan.GeneratedCharacter == sourceMapSpan.GeneratedLine { // !!! char == line seems like a bug in Strada? + if len(w.spansOnSingleLine) > 0 && int(w.spansOnSingleLine[0].sourceMapSpan.GeneratedCharacter) == sourceMapSpan.GeneratedLine { // !!! char == line seems like a bug in Strada? w.writeRecordedSpans() w.spansOnSingleLine = nil w.nextJsLineToWrite-- // walk back one line to reprint the line @@ -260,7 +260,7 @@ func (sw *recordedSpanWriter) iterateSpans(fn func(currentSpan *sourceMapSpanWit sw.prevEmittedCol = 0 for i := range len(sw.w.spansOnSingleLine) { fn(&sw.w.spansOnSingleLine[i], i) - sw.prevEmittedCol = sw.w.spansOnSingleLine[i].sourceMapSpan.GeneratedCharacter + sw.prevEmittedCol = int(sw.w.spansOnSingleLine[i].sourceMapSpan.GeneratedCharacter) } } @@ -272,7 +272,7 @@ func (sw *recordedSpanWriter) writeSourceMapIndent(indentLength int, indentPrefi } func (sw *recordedSpanWriter) writeSourceMapMarker(currentSpan *sourceMapSpanWithDecodeErrors, index int) { - sw.writeSourceMapMarkerEx(currentSpan, index, currentSpan.sourceMapSpan.GeneratedCharacter, false /*endContinues*/) + sw.writeSourceMapMarkerEx(currentSpan, index, int(currentSpan.sourceMapSpan.GeneratedCharacter), false /*endContinues*/) } func (sw *recordedSpanWriter) writeSourceMapMarkerEx(currentSpan *sourceMapSpanWithDecodeErrors, index int, endColumn int, endContinues bool) { diff --git a/internal/testutil/tsbaseline/type_symbol_baseline.go b/internal/testutil/tsbaseline/type_symbol_baseline.go index 3521bd5442..6fb892d5a8 100644 --- a/internal/testutil/tsbaseline/type_symbol_baseline.go +++ b/internal/testutil/tsbaseline/type_symbol_baseline.go @@ -442,7 +442,7 @@ func (walker *typeWriterWalker) writeTypeOrSymbol(node *ast.Node, isSymbolWalk b if isDefaultLibraryFile(fileName) { symbolString.WriteString("--, --)") } else { - fmt.Fprintf(&symbolString, "%d, %d)", declLine, declChar) + fmt.Fprintf(&symbolString, "%d, %d)", declLine, int(declChar)) } } symbolString.WriteString(")") diff --git a/internal/transformers/jsxtransforms/jsx.go b/internal/transformers/jsxtransforms/jsx.go index 88f77726c8..216fe2e588 100644 --- a/internal/transformers/jsxtransforms/jsx.go +++ b/internal/transformers/jsxtransforms/jsx.go @@ -594,7 +594,7 @@ func (tx *JSXTransformer) visitJsxOpeningLikeElementOrFragmentJSX( args = append(args, tx.Factory().NewObjectLiteralExpression(tx.Factory().NewNodeList([]*ast.Node{ tx.Factory().NewPropertyAssignment(nil, tx.Factory().NewIdentifier("fileName"), nil, nil, tx.getCurrentFileNameExpression()), tx.Factory().NewPropertyAssignment(nil, tx.Factory().NewIdentifier("lineNumber"), nil, nil, tx.Factory().NewNumericLiteral(strconv.FormatInt(int64(line+1), 10), ast.TokenFlagsNone)), - tx.Factory().NewPropertyAssignment(nil, tx.Factory().NewIdentifier("columnNumber"), nil, nil, tx.Factory().NewNumericLiteral(strconv.FormatInt(int64(col+1), 10), ast.TokenFlagsNone)), + tx.Factory().NewPropertyAssignment(nil, tx.Factory().NewIdentifier("columnNumber"), nil, nil, tx.Factory().NewNumericLiteral(strconv.FormatInt(int64(col)+1, 10), ast.TokenFlagsNone)), }), false)) // __self development flag args = append(args, tx.Factory().NewThisExpression()) From 6281436aa4225d1ccf686406b0c1425a2037d41d Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 23 Feb 2026 12:02:52 -0800 Subject: [PATCH 7/9] Speed up UTF16Len --- internal/core/core.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/core/core.go b/internal/core/core.go index ae4d42db55..665c2dda9b 100644 --- a/internal/core/core.go +++ b/internal/core/core.go @@ -457,11 +457,19 @@ type UTF16Offset int // UTF16Len returns the number of UTF-16 code units needed to // represent the given UTF-8 encoded string. func UTF16Len(s string) UTF16Offset { - n := UTF16Offset(0) - for _, r := range s { - n += UTF16Offset(utf16.RuneLen(r)) + // Fast path: scan for non-ASCII bytes. For ASCII-only strings, + // each byte is one UTF-16 code unit, so we can return len(s) directly. + for i := 0; i < len(s); i++ { + if s[i] >= utf8.RuneSelf { + // Found non-ASCII; count the ASCII prefix, then decode the rest. + n := UTF16Offset(i) + for _, r := range s[i:] { + n += UTF16Offset(utf16.RuneLen(r)) + } + return n + } } - return n + return UTF16Offset(len(s)) } func Flatten[T any](array [][]T) []T { From 8d8087668d122178113ca3bdb0bac65230d28651 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 23 Feb 2026 12:11:32 -0800 Subject: [PATCH 8/9] lint fix --- internal/core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/core/core.go b/internal/core/core.go index 665c2dda9b..294944cf95 100644 --- a/internal/core/core.go +++ b/internal/core/core.go @@ -459,7 +459,7 @@ type UTF16Offset int func UTF16Len(s string) UTF16Offset { // Fast path: scan for non-ASCII bytes. For ASCII-only strings, // each byte is one UTF-16 code unit, so we can return len(s) directly. - for i := 0; i < len(s); i++ { + for i := range len(s) { if s[i] >= utf8.RuneSelf { // Found non-ASCII; count the ASCII prefix, then decode the rest. n := UTF16Offset(i) From 8c90fe7706a80a018b668421794b1b0be05a0743 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 23 Feb 2026 12:19:07 -0800 Subject: [PATCH 9/9] Copilot feedback --- internal/diagnosticwriter/diagnosticwriter.go | 4 ++-- internal/scanner/scanner.go | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/diagnosticwriter/diagnosticwriter.go b/internal/diagnosticwriter/diagnosticwriter.go index 4c6aa0255f..215994f0fc 100644 --- a/internal/diagnosticwriter/diagnosticwriter.go +++ b/internal/diagnosticwriter/diagnosticwriter.go @@ -231,7 +231,7 @@ func writeCodeSnippet(writer io.Writer, sourceFile FileLike, start int, length i if i == lastLine { lastCharForLine = int(lastLineChar) } else { - lastCharForLine = len(lineContent) + lastCharForLine = int(core.UTF16Len(lineContent)) } // Fill with spaces until the first character, @@ -243,7 +243,7 @@ func writeCodeSnippet(writer io.Writer, sourceFile FileLike, start int, length i fmt.Fprint(writer, strings.Repeat("~", int(lastLineChar))) default: // Squiggle the entire line. - fmt.Fprint(writer, strings.Repeat("~", len(lineContent))) + fmt.Fprint(writer, strings.Repeat("~", int(core.UTF16Len(lineContent)))) } fmt.Fprint(writer, resetEscapeSequence) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index b71277b24e..b9e035bb35 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -2552,10 +2552,15 @@ func ComputePositionOfLineAndUTF16Character(lineStarts []core.TextPos, line int, utf16Count += core.UTF16Offset(utf16.RuneLen(r)) pos += size } - if allowEdits { - if pos > len(text) { - return len(text) + if !allowEdits { + if pos == lineEnd && utf16Count < character { + panic(fmt.Sprintf("Bad UTF-16 character offset. Line: %d, character: %d.", line, character)) } + debug.Assert(pos <= len(text)) + return pos + } + if pos > len(text) { + return len(text) } return pos }