Skip to content

Commit 4d00f82

Browse files
committed
chore: update typescript-go submodule (#785)
1 parent b4f666b commit 4d00f82

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+301
-326
lines changed

cmd/tsgolint/main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ import (
8383

8484
"github.com/microsoft/typescript-go/shim/ast"
8585
"github.com/microsoft/typescript-go/shim/bundled"
86+
"github.com/microsoft/typescript-go/shim/core"
8687
"github.com/microsoft/typescript-go/shim/scanner"
8788
"github.com/microsoft/typescript-go/shim/tspath"
8889
"github.com/microsoft/typescript-go/shim/vfs/cachedvfs"
@@ -235,23 +236,23 @@ func printDiagnostic(d rule.RuleDiagnostic, w *bufio.Writer, comparePathOptions
235236
diagnosticStart := d.Range.Pos()
236237
diagnosticEnd := d.Range.End()
237238

238-
diagnosticStartLine, diagnosticStartColumn := scanner.GetECMALineAndCharacterOfPosition(d.SourceFile, diagnosticStart)
239-
diagnosticEndline, _ := scanner.GetECMALineAndCharacterOfPosition(d.SourceFile, diagnosticEnd)
239+
diagnosticStartLine, diagnosticStartColumn := scanner.GetECMALineAndUTF16CharacterOfPosition(d.SourceFile, diagnosticStart)
240+
diagnosticEndline, _ := scanner.GetECMALineAndUTF16CharacterOfPosition(d.SourceFile, diagnosticEnd)
240241

241242
lineMap := d.SourceFile.ECMALineMap()
242243
text := d.SourceFile.Text()
243244

244245
codeboxStartLine := max(diagnosticStartLine-1, 0)
245246
codeboxEndLine := min(diagnosticEndline+1, len(lineMap)-1)
246247

247-
codeboxStart := scanner.GetECMAPositionOfLineAndCharacter(d.SourceFile, codeboxStartLine, 0)
248+
codeboxStart := scanner.GetECMAPositionOfLineAndUTF16Character(d.SourceFile, codeboxStartLine, 0)
248249
var codeboxEndColumn int
249250
if codeboxEndLine == len(lineMap)-1 {
250251
codeboxEndColumn = len(text) - int(lineMap[len(lineMap)-1])
251252
} else {
252253
codeboxEndColumn = int(lineMap[codeboxEndLine+1]-lineMap[codeboxEndLine]) - 1
253254
}
254-
codeboxEnd := scanner.GetECMAPositionOfLineAndCharacter(d.SourceFile, codeboxEndLine, codeboxEndColumn)
255+
codeboxEnd := scanner.GetECMAPositionOfLineAndUTF16Character(d.SourceFile, codeboxEndLine, core.UTF16Offset(codeboxEndColumn))
255256

256257
w.Write([]byte{' ', 0x1b, '[', '7', 'm', 0x1b, '[', '1', 'm', 0x1b, '[', '3', '8', ';', '5', ';', '3', '7', 'm', ' '})
257258
w.WriteString(d.RuleName)
@@ -273,7 +274,7 @@ func printDiagnostic(d rule.RuleDiagnostic, w *bufio.Writer, comparePathOptions
273274
w.WriteByte(':')
274275
w.WriteString(strconv.Itoa(diagnosticStartLine + 1))
275276
w.WriteByte(':')
276-
w.WriteString(strconv.Itoa(diagnosticStartColumn + 1))
277+
w.WriteString(strconv.Itoa(int(diagnosticStartColumn) + 1))
277278
w.WriteString("\x1b[0m \x1b[2m)─────\x1b[0m\n")
278279

279280
indentSize := math.MaxInt

cmd/tsgolint/overlayfs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ func (o *overlayFS) ReadFile(path string) (string, bool) {
3636
return o.underlying.ReadFile(path)
3737
}
3838

39-
func (o *overlayFS) WriteFile(path string, data string, writeByteOrderMark bool) error {
40-
return o.underlying.WriteFile(path, data, writeByteOrderMark)
39+
func (o *overlayFS) WriteFile(path string, data string) error {
40+
return o.underlying.WriteFile(path, data)
4141
}
4242

4343
func (o *overlayFS) Remove(path string) error {

e2e/__snapshots__/snapshot.test.ts.snap

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,19 @@ exports[`TSGoLint E2E Snapshot Tests > should generate consistent diagnostics sn
899899
},
900900
"rule": "no-implied-eval",
901901
},
902+
{
903+
"file_path": "fixtures/basic/rules/no-implied-eval/index.ts",
904+
"kind": 0,
905+
"message": {
906+
"description": "Unsafe call of a(n) \`any\` typed value.",
907+
"id": "unsafeCall",
908+
},
909+
"range": {
910+
"end": 139,
911+
"pos": 127,
912+
},
913+
"rule": "no-unsafe-call",
914+
},
902915
{
903916
"file_path": "fixtures/basic/rules/no-meaningless-void-operator/index.ts",
904917
"kind": 0,
@@ -3537,19 +3550,6 @@ exports[`TSGoLint E2E Snapshot Tests > should generate consistent diagnostics sn
35373550
},
35383551
],
35393552
},
3540-
{
3541-
"file_path": "fixtures/basic/rules/unbound-method/index.ts",
3542-
"kind": 0,
3543-
"message": {
3544-
"description": "Value-returning function used in a context where a void function is expected.",
3545-
"id": "nonVoidFunc",
3546-
},
3547-
"range": {
3548-
"end": 565,
3549-
"pos": 557,
3550-
},
3551-
"rule": "strict-void-return",
3552-
},
35533553
{
35543554
"file_path": "fixtures/basic/rules/unbound-method/index.ts",
35553555
"kind": 0,

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ require (
4242
github.com/google/go-cmp v0.7.0 // indirect
4343
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
4444
github.com/zeebo/xxh3 v1.1.0 // indirect
45-
golang.org/x/mod v0.32.0 // indirect
45+
golang.org/x/mod v0.33.0 // indirect
4646
golang.org/x/sync v0.19.0 // indirect
4747
)
4848

4949
require (
5050
github.com/dlclark/regexp2 v1.11.5
51-
github.com/go-json-experiment/json d219187c3433
52-
github.com/microsoft/typescript-go v0.0.0-20260207160609-5597f4c8ecf4 // indirect
51+
github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433
52+
github.com/microsoft/typescript-go v0.0.0-20260309214900-4a59cd78390d // indirect
5353
golang.org/x/text v0.34.0
5454
)

go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
22
github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
3-
github.com/go-json-experiment/json v0.0.0-20251027170946-4849db3c2f7e h1:Lf/gRkoycfOBPa42vU2bbgPurFong6zXeFtPoxholzU=
4-
github.com/go-json-experiment/json v0.0.0-20251027170946-4849db3c2f7e/go.mod h1:uNVvRXArCGbZ508SxYYTC5v1JWoz2voff5pm25jU1Ok=
3+
github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 h1:vymEbVwYFP/L05h5TKQxvkXoKxNvTpjxYKdF1Nlwuao=
4+
github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg=
55
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
66
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
77
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
88
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
9-
github.com/microsoft/typescript-go v0.0.0-20260207160609-5597f4c8ecf4 h1:NJ6/IMy+iDMEuxBqkugTicaoaZtW68r6iVpgE/4n/O4=
10-
github.com/microsoft/typescript-go v0.0.0-20260207160609-5597f4c8ecf4/go.mod h1:YrrCoa1kn/B+vCZ0byeA/7VoRYvUjKryjMz5jX9Un18=
9+
github.com/microsoft/typescript-go v0.0.0-20260309214900-4a59cd78390d h1:TF9iuMrjoNGAQit8uNPcI1VxHqO/ewAQZlhGNei7kTY=
10+
github.com/microsoft/typescript-go v0.0.0-20260309214900-4a59cd78390d/go.mod h1:GO2o1f4S8ffXDYq+wXWUPwDcyulNVCy0JnU6u6+qK0U=
1111
github.com/peter-evans/patience v0.3.0 h1:rX0JdJeepqdQl1Sk9c9uvorjYYzL2TfgLX1adqYm9cA=
1212
github.com/peter-evans/patience v0.3.0/go.mod h1:Kmxu5sY1NmBLFSStvXjX1wS9mIv7wMcP/ubucyMOAu0=
1313
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
1414
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
1515
github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
1616
github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
17-
golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
18-
golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
17+
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
18+
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
1919
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
2020
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
21-
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
22-
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
23-
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
24-
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
25-
golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc=
26-
golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg=
21+
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
22+
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
23+
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
24+
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
25+
golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
26+
golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
2727
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
2828
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=

internal/rule_tester/__snapshots__/consistent-type-exports.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Message: All exports in the declaration are only used as types. Use `export type
77
---
88

99
[TestConsistentTypeExportsRule/invalid-1 - 1]
10-
Diagnostic 1: typeOverValue (1:1 - 1:57)
10+
Diagnostic 1: typeOverValue (1:1 - 1:58)
1111
Message: All exports in the declaration are only used as types. Use `export type`.
1212
1 | export { Type1 as "🍎" } from './consistent-type-exports';
13-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1414
---
1515

1616
[TestConsistentTypeExportsRule/invalid-2 - 1]

internal/rule_tester/__snapshots__/no-unnecessary-template-expression.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,10 +833,10 @@ Message: Template literal expression is unnecessary and can be simplified.
833833
---
834834

835835
[TestNoUnnecessaryTemplateExpressionRule/invalid-95 - 1]
836-
Diagnostic 1: noUnnecessaryTemplateExpression (1:3 - 1:14)
836+
Diagnostic 1: noUnnecessaryTemplateExpression (1:3 - 1:18)
837837
Message: Template literal expression is unnecessary and can be simplified.
838838
1 | ` ${'👨‍👩‍👧‍👦'} `;
839-
| ~~~~~~~~~~~~
839+
| ~~~~~~~~~~~~~~~~
840840
---
841841

842842
[TestNoUnnecessaryTemplateExpressionRule/invalid-96 - 1]

internal/rule_tester/__snapshots__/prefer-string-starts-ends-with.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ Message: Use 'String#startsWith' method instead.
6363
---
6464

6565
[TestPreferStringStartsEndsWithRule/invalid-7 - 1]
66-
Diagnostic 1: preferStartsWith (3:11 - 3:22)
66+
Diagnostic 1: preferStartsWith (3:11 - 3:23)
6767
Message: Use 'String#startsWith' method instead.
6868
2 | function f(s: string) {
6969
3 | s[0] === '👍'; // the length is 2.
70-
| ~~~~~~~~~~~~
70+
| ~~~~~~~~~~~~~
7171
4 | }
7272
---
7373

@@ -144,11 +144,11 @@ Message: Use 'String#startsWith' method instead.
144144
---
145145

146146
[TestPreferStringStartsEndsWithRule/invalid-16 - 1]
147-
Diagnostic 1: preferStartsWith (3:11 - 3:29)
147+
Diagnostic 1: preferStartsWith (3:11 - 3:30)
148148
Message: Use 'String#startsWith' method instead.
149149
2 | function f(s: string) {
150150
3 | s.charAt(0) === '👍'; // the length is 2.
151-
| ~~~~~~~~~~~~~~~~~~~
151+
| ~~~~~~~~~~~~~~~~~~~~
152152
4 | }
153153
---
154154

internal/rule_tester/rule_tester.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ func RunRuleTester(rootDir string, tsconfigPath string, t *testing.T, r *rule.Ru
194194
t.Errorf("Invalid message id %v. Expected %v", diagnostic.Message.Id, expected.MessageId)
195195
}
196196

197-
lineIndex, columnIndex := scanner.GetECMALineAndCharacterOfPosition(diagnostic.SourceFile, diagnostic.Range.Pos())
198-
line, column := lineIndex+1, columnIndex+1
199-
endLineIndex, endColumnIndex := scanner.GetECMALineAndCharacterOfPosition(diagnostic.SourceFile, diagnostic.Range.End())
200-
endLine, endColumn := endLineIndex+1, endColumnIndex+1
197+
lineIndex, columnIndex := scanner.GetECMALineAndUTF16CharacterOfPosition(diagnostic.SourceFile, diagnostic.Range.Pos())
198+
line, column := lineIndex+1, int(columnIndex)+1
199+
endLineIndex, endColumnIndex := scanner.GetECMALineAndUTF16CharacterOfPosition(diagnostic.SourceFile, diagnostic.Range.End())
200+
endLine, endColumn := endLineIndex+1, int(endColumnIndex)+1
201201

202202
if expected.Line != 0 && expected.Line != line {
203203
t.Errorf("Error line should be %v. Got %v", expected.Line, line)

internal/rule_tester/snapshot.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ func renderSourceAnnotation(code string, sourceFile *ast.SourceFile, textRange c
288288
}
289289
}
290290

291-
sl, sc := scanner.GetECMALineAndCharacterOfPosition(sourceFile, startPos)
292-
el, ec := scanner.GetECMALineAndCharacterOfPosition(sourceFile, endPos)
291+
sl, sc := scanner.GetECMALineAndUTF16CharacterOfPosition(sourceFile, startPos)
292+
el, ec := scanner.GetECMALineAndUTF16CharacterOfPosition(sourceFile, endPos)
293293

294294
// Display range with 1 line of context
295295
startLine := max(sl-1, 0)
@@ -317,11 +317,11 @@ func renderSourceAnnotation(code string, sourceFile *ast.SourceFile, textRange c
317317
// Calculate annotation columns for this line
318318
aStart := 0
319319
if lineIdx == sl {
320-
aStart = sc
320+
aStart = int(sc)
321321
}
322322
aEnd := len(lineText)
323323
if lineIdx == el {
324-
aEnd = ec
324+
aEnd = int(ec)
325325
}
326326

327327
adjustedStart := adjustForTabs(lineText, aStart)
@@ -397,15 +397,15 @@ func formatDiagnosticsSnapshot(code string, diagnostics []rule.RuleDiagnostic) s
397397
break
398398
}
399399
}
400-
lineIdx, colIdx := scanner.GetECMALineAndCharacterOfPosition(d.SourceFile, startPos)
401-
line, column = lineIdx+1, colIdx+1
400+
lineIdx, colIdx := scanner.GetECMALineAndUTF16CharacterOfPosition(d.SourceFile, startPos)
401+
line, column = lineIdx+1, int(colIdx)+1
402402
// Use inclusive end (last character in range) for display
403403
inclusiveEnd := d.Range.End()
404404
if inclusiveEnd > startPos {
405405
inclusiveEnd--
406406
}
407-
endLineIdx, endColIdx := scanner.GetECMALineAndCharacterOfPosition(d.SourceFile, inclusiveEnd)
408-
endLine, endColumn = endLineIdx+1, endColIdx+1
407+
endLineIdx, endColIdx := scanner.GetECMALineAndUTF16CharacterOfPosition(d.SourceFile, inclusiveEnd)
408+
endLine, endColumn = endLineIdx+1, int(endColIdx)+1
409409
}
410410

411411
fmt.Fprintf(&sb, "Diagnostic %d: %s (%d:%d - %d:%d)\n", i+1, d.Message.Id, line, column, endLine, endColumn)
@@ -439,15 +439,15 @@ func formatDiagnosticsSnapshot(code string, diagnostics []rule.RuleDiagnostic) s
439439
break
440440
}
441441
}
442-
lrLineIdx, lrColIdx := scanner.GetECMALineAndCharacterOfPosition(d.SourceFile, lrStartPos)
443-
lrLine, lrCol = lrLineIdx+1, lrColIdx+1
442+
lrLineIdx, lrColIdx := scanner.GetECMALineAndUTF16CharacterOfPosition(d.SourceFile, lrStartPos)
443+
lrLine, lrCol = lrLineIdx+1, int(lrColIdx)+1
444444
// Use inclusive end (last character in range) for display
445445
lrInclusiveEnd := lr.Range.End()
446446
if lrInclusiveEnd > lrStartPos {
447447
lrInclusiveEnd--
448448
}
449-
lrEndLineIdx, lrEndColIdx := scanner.GetECMALineAndCharacterOfPosition(d.SourceFile, lrInclusiveEnd)
450-
lrEndLine, lrEndCol = lrEndLineIdx+1, lrEndColIdx+1
449+
lrEndLineIdx, lrEndColIdx := scanner.GetECMALineAndUTF16CharacterOfPosition(d.SourceFile, lrInclusiveEnd)
450+
lrEndLine, lrEndCol = lrEndLineIdx+1, int(lrEndColIdx)+1
451451
}
452452
fmt.Fprintf(&sb, " Label: %s (%d:%d - %d:%d)\n", lr.Label, lrLine, lrCol, lrEndLine, lrEndCol)
453453
labelAnnotated := renderSourceAnnotation(code, d.SourceFile, lr.Range, '^', lr.Label)

0 commit comments

Comments
 (0)