Skip to content

Commit 1fe20a6

Browse files
authoredMar 5, 2025
Update to Go 1.24 (microsoft#339)
1 parent 5778a35 commit 1fe20a6

File tree

25 files changed

+94
-87
lines changed

25 files changed

+94
-87
lines changed
 

‎.custom-gcl.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/custom-gcl.jsonschema.json
22

3-
version: v1.63.4
3+
version: v1.64.6
44

55
destination: ./_tools
66

‎.dprint.jsonc

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"cwd": "${configDir}",
4242
"cacheKey": "4",
4343
"commands": [
44-
{ "command": "gofumpt -lang=go1.23", "exts": ["go"] }
44+
{ "command": "gofumpt -lang=go1.24", "exts": ["go"] }
4545
]
4646
},
4747
"excludes": [

‎.github/actions/setup-go/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Setup Go
44
inputs:
55
go-version:
66
description: Go version range to set up.
7-
default: '>=1.23.0'
7+
default: '>=1.24.0'
88
cache-name:
99
description: Name of scoped cache for this set up.
1010
default: 'cache'

‎_tools/customlint/testdata/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module testdata
22

3-
go 1.23.3
3+
go 1.24.0

‎_tools/go.mod

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module github.com/microsoft/typescript-go/_tools
22

3-
go 1.23.3
3+
go 1.24.0
44

55
require (
66
github.com/golangci/plugin-module-register v0.1.1
7-
golang.org/x/tools v0.27.1-0.20241128223349-e7bd2274d184
8-
gotest.tools/v3 v3.5.1
7+
golang.org/x/tools v0.30.0
8+
gotest.tools/v3 v3.5.2
99
)
1010

1111
require (
1212
github.com/google/go-cmp v0.6.0 // indirect
13-
golang.org/x/mod v0.22.0 // indirect
14-
golang.org/x/sync v0.9.0 // indirect
13+
golang.org/x/mod v0.23.0 // indirect
14+
golang.org/x/sync v0.11.0 // indirect
1515
)

‎_tools/go.sum

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ github.com/golangci/plugin-module-register v0.1.1 h1:TCmesur25LnyJkpsVrupv1Cdzo+
22
github.com/golangci/plugin-module-register v0.1.1/go.mod h1:TTpqoB6KkwOJMV8u7+NyXMrkwwESJLOkfl9TxR1DGFc=
33
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
44
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
5-
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
6-
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
7-
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
8-
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
9-
golang.org/x/tools v0.27.1-0.20241128223349-e7bd2274d184 h1:wi4Jz8kRE1yU2JFOi7/w75M61R6mfyCS24FzCFKMuHI=
10-
golang.org/x/tools v0.27.1-0.20241128223349-e7bd2274d184/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
11-
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
12-
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
5+
golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
6+
golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
7+
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
8+
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
9+
golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
10+
golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
11+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
12+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=

‎go.mod

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
module github.com/microsoft/typescript-go
22

3-
go 1.23.3
3+
go 1.24.0
44

55
require (
6-
github.com/dlclark/regexp2 v1.11.4
7-
github.com/go-json-experiment/json v0.0.0-20241127185351-9802db03f36a
8-
github.com/google/go-cmp v0.6.0
6+
github.com/dlclark/regexp2 v1.11.5
7+
github.com/go-json-experiment/json v0.0.0-20250223041408-d3c622f1b874
8+
github.com/google/go-cmp v0.7.0
99
github.com/pkg/diff v0.0.0-20241224192749-4e6772a4315c
10-
golang.org/x/sys v0.27.0
11-
golang.org/x/tools v0.27.0
12-
gotest.tools/v3 v3.5.1
10+
golang.org/x/sys v0.31.0
11+
gotest.tools/v3 v3.5.2
1312
)
1413

1514
require (
16-
golang.org/x/mod v0.22.0 // indirect
17-
golang.org/x/sync v0.9.0 // indirect
15+
golang.org/x/mod v0.23.0 // indirect
16+
golang.org/x/sync v0.11.0 // indirect
17+
golang.org/x/tools v0.30.0 // indirect
1818
)
19+
20+
tool golang.org/x/tools/cmd/stringer

‎go.sum

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo=
2-
github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
3-
github.com/go-json-experiment/json v0.0.0-20241127185351-9802db03f36a h1:W/o3DbExdFptoPsZlbGsFnm0f8xDce+C0+Y0u54mJo4=
4-
github.com/go-json-experiment/json v0.0.0-20241127185351-9802db03f36a/go.mod h1:BWmvoE1Xia34f3l/ibJweyhrT+aROb/FQ6d+37F0e2s=
5-
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
6-
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1+
github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
2+
github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
3+
github.com/go-json-experiment/json v0.0.0-20250223041408-d3c622f1b874 h1:F8d1AJ6M9UQCavhwmO6ZsrYLfG8zVFWfEfMS2MXPkSY=
4+
github.com/go-json-experiment/json v0.0.0-20250223041408-d3c622f1b874/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M=
5+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
6+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
77
github.com/pkg/diff v0.0.0-20241224192749-4e6772a4315c h1:8TRxBMS/YsupXoOiGKHr9ZOXo+5DezGWPgBAhBHEHto=
88
github.com/pkg/diff v0.0.0-20241224192749-4e6772a4315c/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
9-
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
10-
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
11-
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
12-
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
13-
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
14-
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
15-
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
16-
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
17-
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
18-
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
9+
golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
10+
golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
11+
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
12+
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
13+
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
14+
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
15+
golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
16+
golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
17+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
18+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=

‎internal/ast/kind.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ast
22

3-
//go:generate go run golang.org/x/tools/cmd/stringer -type=Kind -output=kind_stringer_generated.go
3+
//go:generate go tool golang.org/x/tools/cmd/stringer -type=Kind -output=kind_stringer_generated.go
44

55
type Kind int16
66

‎internal/checker/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/microsoft/typescript-go/internal/core"
99
)
1010

11-
//go:generate go run golang.org/x/tools/cmd/stringer -type=SignatureKind -output=stringer_generated.go
11+
//go:generate go tool golang.org/x/tools/cmd/stringer -type=SignatureKind -output=stringer_generated.go
1212

1313
// ParseFlags
1414

‎internal/collections/ordered_map.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ func resolveKeyName(k reflect.Value) (string, error) {
244244
panic("unexpected map key type")
245245
}
246246

247+
var (
248+
_ json.Unmarshaler = (*OrderedMap[string, string])(nil)
249+
_ json2.UnmarshalerFrom = (*OrderedMap[string, string])(nil)
250+
)
251+
247252
func (m *OrderedMap[K, V]) UnmarshalJSON(data []byte) error {
248253
if string(data) == "null" {
249254
// By convention, to approximate the behavior of Unmarshal itself,
@@ -284,7 +289,7 @@ func (m *OrderedMap[K, V]) UnmarshalJSON(data []byte) error {
284289
return nil
285290
}
286291

287-
func (m *OrderedMap[K, V]) UnmarshalJSONV2(dec *jsontext.Decoder, opts json2.Options) error {
292+
func (m *OrderedMap[K, V]) UnmarshalJSONFrom(dec *jsontext.Decoder) error {
288293
token, err := dec.ReadToken()
289294
if err != nil {
290295
return err
@@ -301,10 +306,10 @@ func (m *OrderedMap[K, V]) UnmarshalJSONV2(dec *jsontext.Decoder, opts json2.Opt
301306
for dec.PeekKind() != '}' { // jsontext.ObjectEnd.Kind()
302307
var key K
303308
var value V
304-
if err := json2.UnmarshalDecode(dec, &key, opts); err != nil {
309+
if err := json2.UnmarshalDecode(dec, &key); err != nil {
305310
return err
306311
}
307-
if err := json2.UnmarshalDecode(dec, &value, opts); err != nil {
312+
if err := json2.UnmarshalDecode(dec, &value); err != nil {
308313
return err
309314
}
310315
m.Set(key, value)

‎internal/compiler/diagnostics/diagnostics.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package diagnostics
44
import "github.com/microsoft/typescript-go/internal/stringutil"
55

66
//go:generate go run generate.go -output ./diagnostics_generated.go
7-
//go:generate go run golang.org/x/tools/cmd/stringer -type=Category -output=stringer_generated.go
7+
//go:generate go tool golang.org/x/tools/cmd/stringer -type=Category -output=stringer_generated.go
88

99
type Category int32
1010

‎internal/compiler/packagejson/exportsorimports.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package packagejson
22

33
import (
4+
"encoding/json"
5+
46
json2 "github.com/go-json-experiment/json"
57
"github.com/go-json-experiment/json/jsontext"
68
"github.com/microsoft/typescript-go/internal/collections"
@@ -21,12 +23,17 @@ type ExportsOrImports struct {
2123
objectKind objectKind
2224
}
2325

26+
var (
27+
_ json.Unmarshaler = (*ExportsOrImports)(nil)
28+
_ json2.UnmarshalerFrom = (*ExportsOrImports)(nil)
29+
)
30+
2431
func (e *ExportsOrImports) UnmarshalJSON(data []byte) error {
2532
return unmarshalJSONValue[ExportsOrImports](&e.JSONValue, data)
2633
}
2734

28-
func (e *ExportsOrImports) UnmarshalJSONV2(dec *jsontext.Decoder, opts json2.Options) error {
29-
return unmarshalJSONValueV2[ExportsOrImports](&e.JSONValue, dec, opts)
35+
func (e *ExportsOrImports) UnmarshalJSONFrom(dec *jsontext.Decoder) error {
36+
return unmarshalJSONValueV2[ExportsOrImports](&e.JSONValue, dec)
3037
}
3138

3239
func (e ExportsOrImports) AsObject() *collections.OrderedMap[string, ExportsOrImports] {

‎internal/compiler/packagejson/jsonvalue.go

+14-9
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,17 @@ func (v JSONValue) AsArray() []JSONValue {
7474
return v.Value.([]JSONValue)
7575
}
7676

77+
var (
78+
_ json.Unmarshaler = (*JSONValue)(nil)
79+
_ json2.UnmarshalerFrom = (*JSONValue)(nil)
80+
)
81+
7782
func (v *JSONValue) UnmarshalJSON(data []byte) error {
7883
return unmarshalJSONValue[JSONValue](v, data)
7984
}
8085

81-
func (v *JSONValue) UnmarshalJSONV2(dec *jsontext.Decoder, opts json2.Options) error {
82-
return unmarshalJSONValueV2[JSONValue](v, dec, opts)
86+
func (v *JSONValue) UnmarshalJSONFrom(dec *jsontext.Decoder) error {
87+
return unmarshalJSONValueV2[JSONValue](v, dec)
8388
}
8489

8590
func unmarshalJSONValue[T any](v *JSONValue, data []byte) error {
@@ -115,7 +120,7 @@ func unmarshalJSONValue[T any](v *JSONValue, data []byte) error {
115120
return nil
116121
}
117122

118-
func unmarshalJSONValueV2[T any](v *JSONValue, dec *jsontext.Decoder, opts json2.Options) error {
123+
func unmarshalJSONValueV2[T any](v *JSONValue, dec *jsontext.Decoder) error {
119124
switch dec.PeekKind() {
120125
case 'n': // jsontext.Null.Kind()
121126
if _, err := dec.ReadToken(); err != nil {
@@ -126,17 +131,17 @@ func unmarshalJSONValueV2[T any](v *JSONValue, dec *jsontext.Decoder, opts json2
126131
return nil
127132
case '"':
128133
v.Type = JSONValueTypeString
129-
if err := json2.UnmarshalDecode(dec, &v.Value, opts); err != nil {
134+
if err := json2.UnmarshalDecode(dec, &v.Value); err != nil {
130135
return err
131136
}
132137
case '[':
133138
if _, err := dec.ReadToken(); err != nil {
134139
return err
135140
}
136141
var elements []T
137-
for dec.PeekKind() != jsontext.ArrayEnd.Kind() {
142+
for dec.PeekKind() != jsontext.EndArray.Kind() {
138143
var element T
139-
if err := json2.UnmarshalDecode(dec, &element, opts); err != nil {
144+
if err := json2.UnmarshalDecode(dec, &element); err != nil {
140145
return err
141146
}
142147
elements = append(elements, element)
@@ -148,19 +153,19 @@ func unmarshalJSONValueV2[T any](v *JSONValue, dec *jsontext.Decoder, opts json2
148153
v.Value = elements
149154
case '{':
150155
var object collections.OrderedMap[string, T]
151-
if err := json2.UnmarshalDecode(dec, &object, opts); err != nil {
156+
if err := json2.UnmarshalDecode(dec, &object); err != nil {
152157
return err
153158
}
154159
v.Type = JSONValueTypeObject
155160
v.Value = &object
156161
case 't', 'f': // jsontext.True.Kind(), jsontext.False.Kind()
157162
v.Type = JSONValueTypeBoolean
158-
if err := json2.UnmarshalDecode(dec, &v.Value, opts); err != nil {
163+
if err := json2.UnmarshalDecode(dec, &v.Value); err != nil {
159164
return err
160165
}
161166
default:
162167
v.Type = JSONValueTypeNumber
163-
if err := json2.UnmarshalDecode(dec, &v.Value, opts); err != nil {
168+
if err := json2.UnmarshalDecode(dec, &v.Value); err != nil {
164169
return err
165170
}
166171
}

‎internal/compiler/packagejson/packagejson_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func BenchmarkPackageJSON(b *testing.B) {
2424
content := []byte(f.ReadFile(b))
2525
b.Run("UnmarshalJSON", func(b *testing.B) {
2626
b.Run(f.Name(), func(b *testing.B) {
27-
for range b.N {
27+
for b.Loop() {
2828
var p packagejson.Fields
2929
if err := json.Unmarshal(content, &p); err != nil {
3030
b.Fatal(err)
@@ -35,7 +35,7 @@ func BenchmarkPackageJSON(b *testing.B) {
3535

3636
b.Run("UnmarshalJSONV2", func(b *testing.B) {
3737
b.Run(f.Name(), func(b *testing.B) {
38-
for range b.N {
38+
for b.Loop() {
3939
var p packagejson.Fields
4040
if err := json2.Unmarshal(content, &p); err != nil {
4141
b.Fatal(err)
@@ -47,7 +47,7 @@ func BenchmarkPackageJSON(b *testing.B) {
4747
b.Run("ParseJSONText", func(b *testing.B) {
4848
b.Run(f.Name(), func(b *testing.B) {
4949
fileName := "/" + f.Name()
50-
for range b.N {
50+
for b.Loop() {
5151
parser.ParseJSONText(fileName, tspath.Path(fileName), string(content))
5252
}
5353
})

‎internal/core/compileroptions.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/microsoft/typescript-go/internal/tspath"
88
)
99

10-
//go:generate go run golang.org/x/tools/cmd/stringer -type=ModuleKind,ScriptTarget -output=compileroptions_stringer_generated.go
10+
//go:generate go tool golang.org/x/tools/cmd/stringer -type=ModuleKind,ScriptTarget -output=compileroptions_stringer_generated.go
1111

1212
type CompilerOptions struct {
1313
AllowJs Tristate `json:"allowJs"`

‎internal/core/languagevariant.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package core
22

3-
//go:generate go run golang.org/x/tools/cmd/stringer -type=LanguageVariant -output=languagevariant_stringer_generated.go
3+
//go:generate go tool golang.org/x/tools/cmd/stringer -type=LanguageVariant -output=languagevariant_stringer_generated.go
44

55
type LanguageVariant int32
66

‎internal/core/scriptkind.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package core
22

3-
//go:generate go run golang.org/x/tools/cmd/stringer -type=ScriptKind -output=scriptkind_stringer_generated.go
3+
//go:generate go tool golang.org/x/tools/cmd/stringer -type=ScriptKind -output=scriptkind_stringer_generated.go
44

55
type ScriptKind int32
66

‎internal/core/tristate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package core
22

3-
//go:generate go run golang.org/x/tools/cmd/stringer -type=Tristate -output=tristate_stringer_generated.go
3+
//go:generate go tool golang.org/x/tools/cmd/stringer -type=Tristate -output=tristate_stringer_generated.go
44

55
// Tristate
66

‎internal/jsnum/jsnum_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,15 @@ func TestToInt32(t *testing.T) {
9191
}
9292
}
9393

94-
var sink int32
95-
9694
func BenchmarkToInt32(b *testing.B) {
9795
for _, test := range toInt32Tests {
9896
if !test.bench {
9997
continue
10098
}
10199

102100
b.Run(fmt.Sprintf("%s (%v)", test.name, float64(test.input)), func(b *testing.B) {
103-
for range b.N {
104-
sink = test.input.toInt32()
101+
for b.Loop() {
102+
test.input.toInt32()
105103
}
106104
})
107105
}

‎internal/parser/parser_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func BenchmarkParse(b *testing.B) {
3838
for _, jsdoc := range jsdocModes {
3939
b.Run(jsdoc.name, func(b *testing.B) {
4040
jsdocMode := jsdoc.mode
41-
for range b.N {
41+
for b.Loop() {
4242
ParseSourceFile(fileName, path, sourceText, core.ScriptTargetESNext, jsdocMode)
4343
}
4444
})

‎internal/project/project.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/microsoft/typescript-go/internal/vfs"
1515
)
1616

17-
//go:generate go run golang.org/x/tools/cmd/stringer -type=Kind -output=project_stringer_generated.go
17+
//go:generate go tool golang.org/x/tools/cmd/stringer -type=Kind -output=project_stringer_generated.go
1818

1919
var projectNamer = &namer{}
2020

‎internal/tools.go

-9
This file was deleted.

‎internal/tsoptions/tsconfigparsing_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -828,9 +828,8 @@ func BenchmarkParseSrcCompiler(b *testing.B) {
828828
parsed := parser.ParseJSONText(tsconfigFileName, tsconfigPath, jsonText)
829829

830830
b.ReportAllocs()
831-
b.ResetTimer()
832831

833-
for range b.N {
832+
for b.Loop() {
834833
tsoptions.ParseJsonSourceFileConfigFileContent(
835834
&tsoptions.TsConfigSourceFile{
836835
SourceFile: parsed,

‎internal/tspath/path_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func BenchmarkCombinePaths(b *testing.B) {
256256
b.Run(name, func(b *testing.B) {
257257
first, rest := test[0], test[1:]
258258
b.ReportAllocs()
259-
for range b.N {
259+
for b.Loop() {
260260
CombinePaths(first, rest...)
261261
}
262262
})
@@ -547,7 +547,7 @@ func BenchmarkToFileNameLowerCase(b *testing.B) {
547547
name := shortenName(test)
548548
b.Run(name, func(b *testing.B) {
549549
b.ReportAllocs()
550-
for range b.N {
550+
for b.Loop() {
551551
ToFileNameLowerCase(test)
552552
}
553553
})
@@ -600,7 +600,7 @@ func BenchmarkHasRelativePathSegment(b *testing.B) {
600600
name := shortenName(tt.p)
601601
b.Run(name, func(b *testing.B) {
602602
b.ReportAllocs()
603-
for range b.N {
603+
for b.Loop() {
604604
hasRelativePathSegment(tt.p)
605605
}
606606
})
@@ -666,7 +666,7 @@ func BenchmarkPathIsRelative(b *testing.B) {
666666
name := shortenName(tt.p)
667667
b.Run(name, func(b *testing.B) {
668668
b.ReportAllocs()
669-
for range b.N {
669+
for b.Loop() {
670670
PathIsRelative(tt.p)
671671
}
672672
})

0 commit comments

Comments
 (0)
Please sign in to comment.