From 7ea9ee1e9c84e7c3f7fcbcad2775343a0a1a5a5e Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 20 Aug 2026 02:41:37 -0700 Subject: [PATCH 1/8] Update to Go 1.27 --- .github/actions/setup-go/action.yml | 2 +- CONTRIBUTING.md | 2 +- go.work | 2 +- tools/customlint/testdata/go.mod | 2 +- tools/go.mod | 2 +- tsc/go.mod | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index f847a1bd61384..05019e9c57be7 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -4,7 +4,7 @@ description: Setup Go inputs: go-version: description: Go version to set up - default: '1.26' + default: '1.27' runs: using: composite diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 813aa73df80c5..6c6d1776bffde 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -75,7 +75,7 @@ In general, things we find useful when reviewing suggestions are: ## Prerequisites -- Go 1.26 +- Go 1.27 - Node.js 24 - npm (the version declared by `packageManager` in `package.json`) - Git diff --git a/go.work b/go.work index e2b190498e8bd..4bfd12b16859f 100644 --- a/go.work +++ b/go.work @@ -1,4 +1,4 @@ -go 1.26 +go 1.27 use ( ./tools diff --git a/tools/customlint/testdata/go.mod b/tools/customlint/testdata/go.mod index 66d975102e455..b2466ae844a46 100644 --- a/tools/customlint/testdata/go.mod +++ b/tools/customlint/testdata/go.mod @@ -1,3 +1,3 @@ module testdata -go 1.26 +go 1.27 diff --git a/tools/go.mod b/tools/go.mod index 0dca5d35ea01f..80b2c1124162b 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -1,6 +1,6 @@ module github.com/microsoft/TypeScript/tools -go 1.26 +go 1.27 require ( github.com/anchore/quill v0.7.1 diff --git a/tsc/go.mod b/tsc/go.mod index 5de91445f175b..bb492f73630c4 100644 --- a/tsc/go.mod +++ b/tsc/go.mod @@ -1,6 +1,6 @@ module github.com/microsoft/TypeScript/tsc -go 1.26 +go 1.27 require ( github.com/Microsoft/go-winio v0.6.2 From 14d1881c8c45ab5b03651bb223806aee539c258f Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 20 Aug 2026 02:42:36 -0700 Subject: [PATCH 2/8] Use encoding/json/v2 --- .golangci.yml | 2 +- NOTICE.txt | 31 ------------------------------- tsc/go.mod | 1 - tsc/go.sum | 2 -- tsc/internal/json/json.go | 5 ++--- 5 files changed, 3 insertions(+), 38 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index b520c5ce2c330..1309650b71452 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -75,7 +75,7 @@ linters: deny: - pkg: 'encoding/json$' desc: 'Use "github.com/microsoft/TypeScript/tsc/internal/json" instead.' - - pkg: 'github.com/go-json-experiment/json' + - pkg: 'encoding/json/v2' desc: 'Use "github.com/microsoft/TypeScript/tsc/internal/json" instead.' forbidigo: diff --git a/NOTICE.txt b/NOTICE.txt index 0c40b1e6165ff..5b005463661cb 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -221,36 +221,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND --------------------------------------------------------- -github.com/go-json-experiment/json v0.0.0-20260623181947-01eb4420fa68 - BSD-3-Clause - - -Copyright 2010 The Go Authors -Copyright 2011 The Go Authors -Copyright 2016 The Go Authors -Copyright 2018 The Go Authors -Copyright 2020 The Go Authors -Copyright 2021 The Go Authors -Copyright 2022 The Go Authors -Copyright 2023 The Go Authors -Copyright 2024 The Go Authors -Copyright (c) 2020 The Go Authors - -Copyright (c) . All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------- - ---------------------------------------------------------- - golang.org/x/sync v0.21.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang @@ -433,4 +403,3 @@ SOFTWARE. --------------------------------------------------------- - diff --git a/tsc/go.mod b/tsc/go.mod index bb492f73630c4..f52266708156d 100644 --- a/tsc/go.mod +++ b/tsc/go.mod @@ -4,7 +4,6 @@ go 1.27 require ( github.com/Microsoft/go-winio v0.6.2 - github.com/go-json-experiment/json v0.0.0-20260623181947-01eb4420fa68 github.com/google/go-cmp v0.7.0 github.com/klauspost/compress v1.19.0 github.com/mackerelio/go-osstat v0.2.7 diff --git a/tsc/go.sum b/tsc/go.sum index 2b6d00df64280..2a8d3cfeb2c7c 100644 --- a/tsc/go.sum +++ b/tsc/go.sum @@ -1,7 +1,5 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/go-json-experiment/json v0.0.0-20260623181947-01eb4420fa68 h1:KZaTBSyshWX3MP5jukJcNSuXDQTO+rNpt0J564dX/eg= -github.com/go-json-experiment/json v0.0.0-20260623181947-01eb4420fa68/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/klauspost/compress v1.19.0 h1:sXLILfc9jV2QYWkzFOPWStmcUVH2RHEB1JCdY2oVvCQ= diff --git a/tsc/internal/json/json.go b/tsc/internal/json/json.go index 53e0169116325..ddacc5b16451a 100644 --- a/tsc/internal/json/json.go +++ b/tsc/internal/json/json.go @@ -2,11 +2,10 @@ package json import ( + "encoding/json/jsontext" + "encoding/json/v2" "io" "slices" - - "github.com/go-json-experiment/json" - "github.com/go-json-experiment/json/jsontext" ) var allowInvalid []json.Options = slices.Clip([]json.Options{jsontext.AllowInvalidUTF8(true)}) From e6a7493c7f5227e6cdc1462462ce48085d2dd730 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 20 Aug 2026 02:48:32 -0700 Subject: [PATCH 3/8] Update Go dependencies --- NOTICE.txt | 10 +++++----- tools/go.mod | 8 ++++---- tools/go.sum | 24 ++++++++++++------------ tsc/go.mod | 14 +++++++------- tsc/go.sum | 28 ++++++++++++++-------------- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 5b005463661cb..46d8787f9b90a 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -221,7 +221,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND --------------------------------------------------------- -golang.org/x/sync v0.21.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang +golang.org/x/sync v0.22.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang Copyright 2009 The Go Authors @@ -236,7 +236,7 @@ BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang --------------------------------------------------------- -golang.org/x/sys v0.46.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang +golang.org/x/sys v0.47.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang Copyright 2009 The Go Authors @@ -264,7 +264,7 @@ BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang --------------------------------------------------------- -golang.org/x/term v0.44.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang +golang.org/x/term v0.45.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang Copyright 2009 The Go Authors @@ -279,7 +279,7 @@ BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang --------------------------------------------------------- -golang.org/x/text v0.38.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang +golang.org/x/text v0.41.0 - BSD-3-Clause AND LicenseRef-scancode-google-patent-license-golang (c) AeHa (c) @@ -351,7 +351,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI --------------------------------------------------------- -github.com/mackerelio/go-osstat v0.2.7 - Apache-2.0 +github.com/mackerelio/go-osstat v0.2.8 - Apache-2.0 Copyright 2017-2019 Hatena Co., Ltd. diff --git a/tools/go.mod b/tools/go.mod index 80b2c1124162b..3b74c6d967b2b 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -6,8 +6,8 @@ require ( github.com/anchore/quill v0.7.1 github.com/blacktop/go-macho v1.1.263 github.com/golangci/plugin-module-register v0.1.2 - golang.org/x/mod v0.37.0 - golang.org/x/tools v0.47.0 + golang.org/x/mod v0.40.0 + golang.org/x/tools v0.49.0 gotest.tools/v3 v3.5.2 ) @@ -21,7 +21,7 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/scylladb/go-set v1.0.3-0.20200225121959-cc7b2070d91e // indirect - golang.org/x/crypto v0.53.0 // indirect - golang.org/x/sync v0.21.0 // indirect + golang.org/x/crypto v0.55.0 // indirect + golang.org/x/sync v0.22.0 // indirect software.sslmate.com/src/go-pkcs12 v0.7.2 // indirect ) diff --git a/tools/go.sum b/tools/go.sum index 67c702b4dbcb9..2074dbe221e69 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -51,22 +51,22 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto= -golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio= -golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ= -golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0= +golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M= +golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis= +golang.org/x/mod v0.40.0 h1:hUv+3cXcdRHz08UmSiOob7sadHig73uo5bkXxQ/tvUs= +golang.org/x/mod v0.40.0/go.mod h1:0/weTWkPWGBikyTWAX3dkjVztMmBA5hM0DH6BElSupE= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= -golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= +golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= -golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= -golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc= -golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y= +golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= +golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0= +golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.47.0 h1:7Kn5x/d1svx/PzryTsqeoZN4TZwqeH5pGWjefhLi/1Q= -golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA= +golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI= +golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/tsc/go.mod b/tsc/go.mod index f52266708156d..80fd41fd3f0e3 100644 --- a/tsc/go.mod +++ b/tsc/go.mod @@ -6,13 +6,13 @@ require ( github.com/Microsoft/go-winio v0.6.2 github.com/google/go-cmp v0.7.0 github.com/klauspost/compress v1.19.0 - github.com/mackerelio/go-osstat v0.2.7 + github.com/mackerelio/go-osstat v0.2.8 github.com/peter-evans/patience v0.3.0 github.com/zeebo/xxh3 v1.1.0 - golang.org/x/sync v0.21.0 - golang.org/x/sys v0.46.0 - golang.org/x/term v0.44.0 - golang.org/x/text v0.38.0 + golang.org/x/sync v0.22.0 + golang.org/x/sys v0.47.0 + golang.org/x/term v0.45.0 + golang.org/x/text v0.41.0 gotest.tools/v3 v3.5.2 ) @@ -20,8 +20,8 @@ require ( github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/matryer/moq v0.7.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - golang.org/x/mod v0.37.0 // indirect - golang.org/x/tools v0.47.0 // indirect + golang.org/x/mod v0.40.0 // indirect + golang.org/x/tools v0.49.0 // indirect ) tool ( diff --git a/tsc/go.sum b/tsc/go.sum index 2a8d3cfeb2c7c..bb33ccdc30a2a 100644 --- a/tsc/go.sum +++ b/tsc/go.sum @@ -6,8 +6,8 @@ github.com/klauspost/compress v1.19.0 h1:sXLILfc9jV2QYWkzFOPWStmcUVH2RHEB1JCdY2o github.com/klauspost/compress v1.19.0/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE= github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= -github.com/mackerelio/go-osstat v0.2.7 h1:TCavZi10wF49bT6iQZ9eT2keGZQpC69MTDfdJej5e94= -github.com/mackerelio/go-osstat v0.2.7/go.mod h1:dwpYh5pIPmvk+IEwBKNIWRFMB92mrC08CmXOhDC7nQk= +github.com/mackerelio/go-osstat v0.2.8 h1:I2duicTaCGWoM53XwAwA9OIe1inu0xnVs8/pqOWWVr4= +github.com/mackerelio/go-osstat v0.2.8/go.mod h1:SyS3XxKdoSKJnTGTkN5Yrh6VUQVuAURACfE6y+2DN4k= github.com/matryer/moq v0.7.1 h1:/QaXqMAdOrLqlshW2z7SMS21jDi7aVrbW0wJrR+hhJk= github.com/matryer/moq v0.7.1/go.mod h1:IabIiFkaKCyHxej25INgFR+fnOxSZFMv2LYrU+ioyDs= github.com/peter-evans/patience v0.3.0 h1:rX0JdJeepqdQl1Sk9c9uvorjYYzL2TfgLX1adqYm9cA= @@ -18,17 +18,17 @@ github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs= github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s= -golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ= -golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0= -golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= -golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= -golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= -golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= -golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc= -golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y= -golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE= -golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4= -golang.org/x/tools v0.47.0 h1:7Kn5x/d1svx/PzryTsqeoZN4TZwqeH5pGWjefhLi/1Q= -golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA= +golang.org/x/mod v0.40.0 h1:hUv+3cXcdRHz08UmSiOob7sadHig73uo5bkXxQ/tvUs= +golang.org/x/mod v0.40.0/go.mod h1:0/weTWkPWGBikyTWAX3dkjVztMmBA5hM0DH6BElSupE= +golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= +golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= +golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0= +golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w= +golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= +golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= +golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI= +golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo= gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= From b28405221d11dc092727ed21e16f554b3b8acd9d Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 20 Aug 2026 02:54:38 -0700 Subject: [PATCH 4/8] Update golangci-lint to 2.13.0 --- .custom-gcl.yml | 2 +- .golangci.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.custom-gcl.yml b/.custom-gcl.yml index ab1990e91cb3d..83d7fbe027f5d 100644 --- a/.custom-gcl.yml +++ b/.custom-gcl.yml @@ -1,6 +1,6 @@ # yaml-language-server: $schema=https://golangci-lint.run/jsonschema/custom-gcl.jsonschema.json -version: v2.12.2 +version: v2.13.0 destination: ./tools diff --git a/.golangci.yml b/.golangci.yml index 1309650b71452..6b1309bfa69f3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -67,6 +67,8 @@ linters: modernize: disable: + - embedlit + - slicesclip - slicesbackward # https://github.com/golang/go/issues/78829 depguard: From 5e6544f2a0c45900b815aa81fb5da12a95d040ea Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 20 Aug 2026 02:55:28 -0700 Subject: [PATCH 5/8] Apply Go 1.27 modernizers --- .golangci.yml | 2 - tsc/internal/compiler/contentmapper_test.go | 2 +- tsc/internal/contentmapper/host_test.go | 138 +++++++------- tsc/internal/contentmapper/transform_test.go | 6 +- .../buildinfo_contentmapper_test.go | 22 +-- tsc/internal/execute/tsc/diagnostics.go | 11 +- tsc/internal/format/api_test.go | 32 ++-- tsc/internal/format/comment_test.go | 176 ++++++++---------- tsc/internal/format/format_test.go | 14 +- tsc/internal/fourslash/test_parser.go | 10 +- tsc/internal/ls/autoimport/extract.go | 6 +- tsc/internal/ls/autoimport/registry_test.go | 58 +++--- tsc/internal/ls/findallreferences.go | 6 +- tsc/internal/ls/lsconv/converters.go | 12 +- tsc/internal/ls/lsutil/formatcodeoptions.go | 24 ++- tsc/internal/lsp/server.go | 16 +- .../modulespecifiers/specifiers_test.go | 6 +- tsc/internal/printer/changetrackerwriter.go | 2 +- tsc/internal/project/api.go | 4 +- tsc/internal/project/contentmapper_test.go | 12 +- tsc/internal/project/dirty/map.go | 27 ++- tsc/internal/project/dirty/syncmap.go | 53 +++--- tsc/internal/project/logging/logcollector.go | 8 +- tsc/internal/project/overlayfs.go | 28 ++- tsc/internal/project/refcountcache_test.go | 8 +- tsc/internal/project/session.go | 24 +-- tsc/internal/project/snapshotfs.go | 2 +- .../testutil/autoimporttestutil/fixtures.go | 2 +- .../testutil/contentmappertest/component.go | 2 +- .../testutil/contentmappertest/duplicate.go | 10 +- .../testutil/contentmappertest/editing.go | 14 +- .../testutil/contentmappertest/lisp.go | 4 +- .../testutil/contentmappertest/mapper_test.go | 16 +- .../contentmappertest/supplemental.go | 2 +- .../supplemental_diagnostics.go | 4 +- .../contentmappertest/supplemental_globals.go | 4 +- .../contentmappertest/supplemental_module.go | 4 +- .../contentmappertest/synthesizing.go | 4 +- .../contentmappertest/transforming.go | 4 +- .../estransforms/taggedtemplate.go | 3 +- tsc/internal/tsoptions/contentmappers_test.go | 8 +- .../tsoptions/tsconfigparsing_test.go | 16 +- 42 files changed, 353 insertions(+), 453 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 6b1309bfa69f3..1309650b71452 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -67,8 +67,6 @@ linters: modernize: disable: - - embedlit - - slicesclip - slicesbackward # https://github.com/golang/go/issues/78829 depguard: diff --git a/tsc/internal/compiler/contentmapper_test.go b/tsc/internal/compiler/contentmapper_test.go index 197914d47aaee..6977d87a1ac4c 100644 --- a/tsc/internal/compiler/contentmapper_test.go +++ b/tsc/internal/compiler/contentmapper_test.go @@ -59,7 +59,7 @@ func newContentMapperProgramWithOptions(t *testing.T, contentMapperProject conte ParsedConfig: &tsoptions.ParsedOptions{ FileNames: rootFiles, CompilerOptions: options, - ContentMappers: []*contentmapper.Mapper{{Definition: contentmapper.Definition{Package: "vue", Extensions: []string{".vue"}}, Manifest: contentmapper.Manifest{Name: "vue-mapper", Version: "1.0.0"}}}, + ContentMappers: []*contentmapper.Mapper{{Package: "vue", Extensions: []string{".vue"}, Name: "vue-mapper", Version: "1.0.0"}}, }, } return compiler.NewProgram(compiler.ProgramOptions{ diff --git a/tsc/internal/contentmapper/host_test.go b/tsc/internal/contentmapper/host_test.go index b5a8a807f2c6b..8a4ee52b26129 100644 --- a/tsc/internal/contentmapper/host_test.go +++ b/tsc/internal/contentmapper/host_test.go @@ -68,7 +68,7 @@ func (fakeMapper) HandleRequest(ctx context.Context, method string, params json. return nil, err } return contentmapper.TransformResult{ - MappedOutput: contentmapper.MappedOutput{Text: p.Content, Extension: ".ts", Mappings: json.Value(mappings)}, + Text: p.Content, Extension: ".ts", Mappings: json.Value(mappings), Diagnostics: []contentmapper.Diagnostic{{ MessageText: "boom", Start: 0, @@ -121,7 +121,7 @@ func (m unicodeMapper) HandleRequest(ctx context.Context, method string, params case contentmapper.PositionEncodingUTF16: emojiLength, textLength = 1, 2 default: - return contentmapper.TransformResult{MappedOutput: contentmapper.MappedOutput{Text: p.Content, Extension: ".ts"}}, nil + return contentmapper.TransformResult{Text: p.Content, Extension: ".ts"}, nil } mappings, err := json.Marshal([][5]int{ {0, emojiLength, 0, emojiLength, int(spanmap.KindVerbatim)}, @@ -131,18 +131,16 @@ func (m unicodeMapper) HandleRequest(ctx context.Context, method string, params return nil, err } return contentmapper.TransformResult{ - MappedOutput: contentmapper.MappedOutput{ - Text: p.Content, - Extension: ".ts", - Mappings: mappings, - DiagnosticDirectives: protocolDiagnosticDirectives([]contentmapper.MappedDiagnosticDirective{{ - OriginalStart: emojiLength, - OriginalLength: textLength - emojiLength, - VirtualStart: emojiLength, - VirtualEnd: textLength, - Policy: contentmapper.DiagnosticDirectivePolicyIgnore, - }}), - }, + Text: p.Content, + Extension: ".ts", + Mappings: mappings, + DiagnosticDirectives: protocolDiagnosticDirectives([]contentmapper.MappedDiagnosticDirective{{ + OriginalStart: emojiLength, + OriginalLength: textLength - emojiLength, + VirtualStart: emojiLength, + VirtualEnd: textLength, + Policy: contentmapper.DiagnosticDirectivePolicyIgnore, + }}), Diagnostics: []contentmapper.Diagnostic{{ MessageText: "after non-ASCII character", Start: emojiLength, @@ -169,7 +167,7 @@ func (m invalidDiagnosticMapper) HandleRequest(ctx context.Context, method strin return contentmapper.InitializeResult{PositionEncoding: m.encoding, DiagnosticSource: "mapper"}, nil case contentmapper.MethodTransform: return contentmapper.TransformResult{ - MappedOutput: contentmapper.MappedOutput{Extension: ".ts"}, + Extension: ".ts", Diagnostics: []contentmapper.Diagnostic{{ MessageText: "invalid boundary", Start: 1, @@ -240,7 +238,7 @@ func TestRunnerTransform(t *testing.T) { r := contentmapper.NewHost(t.Context(), &fakeSpawner{}, locale.Default) defer r.Close() - mapper := &contentmapper.Mapper{Definition: contentmapper.Definition{Extensions: []string{".vue"}}, Manifest: contentmapper.Manifest{Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}}} + mapper := &contentmapper.Mapper{Extensions: []string{".vue"}, Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}} result, err := r.Transform(mapper, contentmapper.Request{FileName: "/a.vue", Content: "export const x = 1;"}) assert.NilError(t, err) assert.Equal(t, result.Text, "export const x = 1;") @@ -267,8 +265,8 @@ func TestHostLogging(t *testing.T) { host := contentmapper.NewHostWithOptions(t.Context(), spawner, locale.Default, contentmapper.HostOptions{Logger: logger}) defer host.Close() mapper := &contentmapper.Mapper{ - Definition: contentmapper.Definition{Package: "configured", Extensions: []string{".vue"}}, - Manifest: contentmapper.Manifest{Name: "resolved", Version: "1.0.0", Exec: []string{"mapper"}}, + Package: "configured", Extensions: []string{".vue"}, + Name: "resolved", Version: "1.0.0", Exec: []string{"mapper"}, } _, err := host.Transform(mapper, contentmapper.Request{FileName: "/a.vue", Content: "export const x = 1;"}) assert.NilError(t, err) @@ -290,8 +288,8 @@ func TestHostDiscardsStderrWithoutLogging(t *testing.T) { host := contentmapper.NewHost(t.Context(), spawner, locale.Default) defer host.Close() mapper := &contentmapper.Mapper{ - Definition: contentmapper.Definition{Package: "configured", Extensions: []string{".vue"}}, - Manifest: contentmapper.Manifest{Name: "resolved", Version: "1.0.0", Exec: []string{"mapper"}}, + Package: "configured", Extensions: []string{".vue"}, + Name: "resolved", Version: "1.0.0", Exec: []string{"mapper"}, } _, err := host.Transform(mapper, contentmapper.Request{FileName: "/a.vue", Content: "export const x = 1;"}) assert.NilError(t, err) @@ -303,8 +301,8 @@ func TestMapperDiagnosticName(t *testing.T) { mapper *contentmapper.Mapper want string }{ - {mapper: &contentmapper.Mapper{Definition: contentmapper.Definition{Package: "configured"}, Manifest: contentmapper.Manifest{Name: "resolved"}, ContributionID: "contributed"}, want: "resolved"}, - {mapper: &contentmapper.Mapper{Definition: contentmapper.Definition{Package: "configured"}, ContributionID: "contributed"}, want: "configured"}, + {mapper: &contentmapper.Mapper{Package: "configured", Name: "resolved", ContributionID: "contributed"}, want: "resolved"}, + {mapper: &contentmapper.Mapper{Package: "configured", ContributionID: "contributed"}, want: "configured"}, {mapper: &contentmapper.Mapper{ContributionID: "contributed"}, want: "contributed"}, } for _, test := range tests { @@ -315,7 +313,7 @@ func TestMapperDiagnosticName(t *testing.T) { func TestRunnerTransformResponseValidation(t *testing.T) { t.Parallel() request := contentmapper.Request{FileName: "/a.vue", Content: "a"} - mapper := &contentmapper.Mapper{Definition: contentmapper.Definition{Extensions: []string{".vue"}}, Manifest: contentmapper.Manifest{Name: "mapper", Exec: []string{"mapper"}}} + mapper := &contentmapper.Mapper{Extensions: []string{".vue"}, Name: "mapper", Exec: []string{"mapper"}} t.Run("malformed result fails the request", func(t *testing.T) { t.Parallel() @@ -350,7 +348,7 @@ func TestHostClosesProcessWhenReadLoopFails(t *testing.T) { }) host := contentmapper.NewHost(t.Context(), spawner, locale.Default) defer host.Close() - mapper := &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: "mapper", Exec: []string{"mapper"}}} + mapper := &contentmapper.Mapper{Name: "mapper", Exec: []string{"mapper"}} _, err := host.Transform(mapper, contentmapper.Request{FileName: "/a.vue", Content: ""}) assert.Assert(t, err != nil) processClosed := false @@ -376,7 +374,7 @@ func TestHostReportsInitializationTimeoutBeforeClosingProcess(t *testing.T) { }) host := contentmapper.NewHost(t.Context(), spawner, locale.Default) defer host.Close() - mapper := &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: "mapper", Exec: []string{"mapper"}}} + mapper := &contentmapper.Mapper{Name: "mapper", Exec: []string{"mapper"}} _, err := host.Transform(mapper, contentmapper.Request{FileName: "/a.vue", Content: ""}) initializeError, ok := errors.AsType[*contentmapper.InitializeError](err) assert.Assert(t, ok, "expected InitializeError, got %v", err) @@ -392,7 +390,7 @@ func TestHostReportsProcessExitBeforeInitialization(t *testing.T) { }) host := contentmapper.NewHost(t.Context(), spawner, locale.Default) defer host.Close() - mapper := &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: "mapper", Exec: []string{"mapper"}}} + mapper := &contentmapper.Mapper{Name: "mapper", Exec: []string{"mapper"}} _, err := host.Transform(mapper, contentmapper.Request{FileName: "/a.vue", Content: ""}) initializeError, ok := errors.AsType[*contentmapper.InitializeError](err) assert.Assert(t, ok, "expected InitializeError, got %v", err) @@ -438,7 +436,7 @@ func (c *closeSignalReadWriteCloser) Close() error { func TestRunnerTransformDiagnosticDirectives(t *testing.T) { t.Parallel() request := contentmapper.Request{FileName: "/a.vue", Content: "directive\nsource"} - mapper := &contentmapper.Mapper{Definition: contentmapper.Definition{Extensions: []string{".vue"}}, Manifest: contentmapper.Manifest{Name: "mapper", Exec: []string{"mapper"}}} + mapper := &contentmapper.Mapper{Extensions: []string{".vue"}, Name: "mapper", Exec: []string{"mapper"}} transform := func(output contentmapper.MappedOutput) (contentmapper.Result, error) { host := contentmapper.NewHost(t.Context(), &fakeSpawner{handler: responseMapper{response: func(p contentmapper.TransformParams) any { return contentmapper.TransformResult{MappedOutput: output} @@ -649,21 +647,21 @@ func TestRunnerTransformSupplementalOutputs(t *testing.T) { t.Parallel() host := contentmapper.NewHost(t.Context(), &fakeSpawner{handler: responseMapper{response: func(p contentmapper.TransformParams) any { return contentmapper.TransformResult{ - MappedOutput: contentmapper.MappedOutput{Text: "export default 1;", Extension: ".ts"}, + Text: "export default 1;", Extension: ".ts", Supplemental: []contentmapper.SupplementalOutput{ - {MappedOutput: contentmapper.MappedOutput{ + { Text: "declare const first: string;", Extension: ".ts", DiagnosticDirectives: protocolDiagnosticDirectives([]contentmapper.MappedDiagnosticDirective{{ VirtualEnd: 7, Policy: contentmapper.DiagnosticDirectivePolicyIgnore, }}), - }}, - {MappedOutput: contentmapper.MappedOutput{Text: "declare const second: number;", Extension: ".mjs"}}, + }, + {Text: "declare const second: number;", Extension: ".mjs"}, }, } }}}, locale.Default) defer host.Close() - mapper := &contentmapper.Mapper{Definition: contentmapper.Definition{Extensions: []string{".vue"}}, Manifest: contentmapper.Manifest{Name: "mapper", Exec: []string{"mapper"}}} + mapper := &contentmapper.Mapper{Extensions: []string{".vue"}, Name: "mapper", Exec: []string{"mapper"}} result, err := host.Transform(mapper, contentmapper.Request{FileName: "/component.vue", Content: "component"}) assert.NilError(t, err) assert.Equal(t, len(result.Supplemental), 2) @@ -680,22 +678,20 @@ func TestRunnerTransformInvalidSupplementalDiagnosticDirective(t *testing.T) { t.Parallel() host := contentmapper.NewHost(t.Context(), &fakeSpawner{handler: responseMapper{response: func(p contentmapper.TransformParams) any { return contentmapper.TransformResult{ - MappedOutput: contentmapper.MappedOutput{Text: "export {};", Extension: ".ts"}, + Text: "export {};", Extension: ".ts", Supplemental: []contentmapper.SupplementalOutput{ - {MappedOutput: contentmapper.MappedOutput{Text: "export {};", Extension: ".ts"}}, + {Text: "export {};", Extension: ".ts"}, { - MappedOutput: contentmapper.MappedOutput{ - Text: "export {};", Extension: ".ts", - DiagnosticDirectives: protocolDiagnosticDirectives([]contentmapper.MappedDiagnosticDirective{{ - Policy: contentmapper.DiagnosticDirectivePolicyExpect, - }}), - }, + Text: "export {};", Extension: ".ts", + DiagnosticDirectives: protocolDiagnosticDirectives([]contentmapper.MappedDiagnosticDirective{{ + Policy: contentmapper.DiagnosticDirectivePolicyExpect, + }}), }, }, } }}}, locale.Default) defer host.Close() - mapper := &contentmapper.Mapper{Definition: contentmapper.Definition{Extensions: []string{".vue"}}, Manifest: contentmapper.Manifest{Name: "mapper", Exec: []string{"mapper"}}} + mapper := &contentmapper.Mapper{Extensions: []string{".vue"}, Name: "mapper", Exec: []string{"mapper"}} _, err := host.Transform(mapper, contentmapper.Request{FileName: "/component.vue", Content: "component"}) directiveError, ok := errors.AsType[*contentmapper.DiagnosticDirectiveError](err) assert.Assert(t, ok) @@ -715,15 +711,15 @@ func TestRunnerRejectsInvalidVirtualExtension(t *testing.T) { var supplementalOutputs []contentmapper.SupplementalOutput if supplemental { canonicalExtension = ".ts" - supplementalOutputs = []contentmapper.SupplementalOutput{{MappedOutput: contentmapper.MappedOutput{Text: "export {};", Extension: extension}}} + supplementalOutputs = []contentmapper.SupplementalOutput{{Text: "export {};", Extension: extension}} } return contentmapper.TransformResult{ - MappedOutput: contentmapper.MappedOutput{Text: "export {};", Extension: canonicalExtension}, + Text: "export {};", Extension: canonicalExtension, Supplemental: supplementalOutputs, } }}}, locale.Default) defer host.Close() - mapper := &contentmapper.Mapper{Definition: contentmapper.Definition{Extensions: []string{".vue"}}, Manifest: contentmapper.Manifest{Name: "mapper", Exec: []string{"mapper"}}} + mapper := &contentmapper.Mapper{Extensions: []string{".vue"}, Name: "mapper", Exec: []string{"mapper"}} _, err := host.Transform(mapper, contentmapper.Request{FileName: "/component.vue", Content: "component"}) assert.ErrorContains(t, err, "invalid virtual extension") }) @@ -741,7 +737,7 @@ func TestRunnerPositionEncodings(t *testing.T) { t.Parallel() r := contentmapper.NewHost(t.Context(), &fakeSpawner{handler: unicodeMapper{encoding: encoding}}, locale.Default) defer r.Close() - mapper := &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: string(encoding), Exec: []string{"mapper"}}} + mapper := &contentmapper.Mapper{Name: string(encoding), Exec: []string{"mapper"}} result, err := r.Transform(mapper, contentmapper.Request{FileName: "/a.vue", Content: "éx"}) assert.NilError(t, err) segments := result.Mappings.Segments() @@ -770,7 +766,7 @@ func TestRunnerRejectsUnsupportedPositionEncoding(t *testing.T) { t.Parallel() r := contentmapper.NewHost(t.Context(), &fakeSpawner{handler: unicodeMapper{encoding: "utf-32"}}, locale.Default) defer r.Close() - mapper := &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: "invalid", Exec: []string{"mapper"}}} + mapper := &contentmapper.Mapper{Name: "invalid", Exec: []string{"mapper"}} _, err := r.Transform(mapper, contentmapper.Request{FileName: "/a.vue", Content: "x"}) assert.ErrorContains(t, err, "unsupported position encoding") } @@ -783,7 +779,7 @@ func TestRunnerRejectsInvalidDiagnosticSource(t *testing.T) { handler := unicodeMapper{encoding: contentmapper.PositionEncodingUTF8, source: &source} r := contentmapper.NewHost(t.Context(), &fakeSpawner{handler: handler}, locale.Default) defer r.Close() - mapper := &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: "invalid", Exec: []string{"mapper"}}} + mapper := &contentmapper.Mapper{Name: "invalid", Exec: []string{"mapper"}} _, err := r.Transform(mapper, contentmapper.Request{FileName: "/a.vue", Content: "x"}) if strings.TrimSpace(source) == "" { assert.ErrorContains(t, err, "diagnostic source must not be empty") @@ -807,7 +803,7 @@ func TestRunnerRejectsPositionsInsideUnicodeCharacters(t *testing.T) { t.Parallel() r := contentmapper.NewHost(t.Context(), &fakeSpawner{handler: invalidDiagnosticMapper{encoding: test.encoding}}, locale.Default) defer r.Close() - mapper := &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: string(test.encoding), Exec: []string{"mapper"}}} + mapper := &contentmapper.Mapper{Name: string(test.encoding), Exec: []string{"mapper"}} _, err := r.Transform(mapper, contentmapper.Request{FileName: "/a.vue", Content: test.content}) assert.ErrorContains(t, err, "splits a Unicode code point") }) @@ -821,9 +817,9 @@ func TestRunnerConsolidatesByIdentity(t *testing.T) { defer r.Close() // Two logically-separate mappers with the same identity share one process. - vueA := &contentmapper.Mapper{Definition: contentmapper.Definition{Package: "a"}, Manifest: contentmapper.Manifest{Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}}} - vueB := &contentmapper.Mapper{Definition: contentmapper.Definition{Package: "b"}, Manifest: contentmapper.Manifest{Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}}} - svelte := &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: "svelte", Version: "2.0.0", Exec: []string{"svelte-mapper"}}} + vueA := &contentmapper.Mapper{Package: "a", Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}} + vueB := &contentmapper.Mapper{Package: "b", Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}} + svelte := &contentmapper.Mapper{Name: "svelte", Version: "2.0.0", Exec: []string{"svelte-mapper"}} project := r.Project(contentmapper.ProjectSpec{Mappers: []*contentmapper.Mapper{vueA, vueB, svelte}, CompilerOptions: &core.CompilerOptions{}}) defer project.Close() @@ -840,9 +836,9 @@ func TestRunnerLeaseLifecycle(t *testing.T) { r := contentmapper.NewHost(t.Context(), &spawner, locale.Default) defer r.Close() - vueA := &contentmapper.Mapper{Definition: contentmapper.Definition{Package: "a"}, Manifest: contentmapper.Manifest{Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}}} - vueB := &contentmapper.Mapper{Definition: contentmapper.Definition{Package: "b"}, Manifest: contentmapper.Manifest{Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}}} - svelte := &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: "svelte", Version: "2.0.0", Exec: []string{"svelte-mapper"}}} + vueA := &contentmapper.Mapper{Package: "a", Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}} + vueB := &contentmapper.Mapper{Package: "b", Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}} + svelte := &contentmapper.Mapper{Name: "svelte", Version: "2.0.0", Exec: []string{"svelte-mapper"}} releaseVueA := r.Acquire([]*contentmapper.Mapper{vueA, vueA}) releaseVueB := r.Acquire([]*contentmapper.Mapper{vueB}) @@ -966,7 +962,7 @@ func (m *recordingMapper) HandleRequest(ctx context.Context, method string, para m.transformHandle = p.ProjectHandle m.transformParams = string(params) m.mu.Unlock() - return contentmapper.TransformResult{MappedOutput: contentmapper.MappedOutput{Text: p.Content, Extension: ".ts"}}, nil + return contentmapper.TransformResult{Text: p.Content, Extension: ".ts"}, nil default: return nil, fmt.Errorf("unexpected method %s", method) } @@ -980,8 +976,8 @@ func TestProjectLifecycle(t *testing.T) { defer host.Close() staticMapper := &contentmapper.Mapper{ - Definition: contentmapper.Definition{Options: []byte(`{"mode":"static"}`)}, - Manifest: contentmapper.Manifest{Name: "static", Version: "1.0.0", Exec: []string{"mapper"}}, + Options: []byte(`{"mode":"static"}`), + Name: "static", Version: "1.0.0", Exec: []string{"mapper"}, } staticProject := host.Project(contentmapper.ProjectSpec{ ConfigFileName: "/repo/tsconfig.json", @@ -995,12 +991,12 @@ func TestProjectLifecycle(t *testing.T) { assert.NilError(t, staticProject.Close()) dynamicA := &contentmapper.Mapper{ - Definition: contentmapper.Definition{Options: []byte(`{"mode":"a"}`)}, - Manifest: contentmapper.Manifest{Name: "dynamic", Version: "1.0.0", Exec: []string{"mapper"}, CompilerOptions: []string{"jsx"}, DynamicConfig: true}, + Options: []byte(`{"mode":"a"}`), + Name: "dynamic", Version: "1.0.0", Exec: []string{"mapper"}, CompilerOptions: []string{"jsx"}, DynamicConfig: true, } dynamicB := &contentmapper.Mapper{ - Definition: contentmapper.Definition{Options: []byte(`{"mode":"b"}`)}, - Manifest: contentmapper.Manifest{Name: "dynamic", Version: "1.0.0", Exec: []string{"mapper"}, DynamicConfig: true}, + Options: []byte(`{"mode":"b"}`), + Name: "dynamic", Version: "1.0.0", Exec: []string{"mapper"}, DynamicConfig: true, } dynamicAOptions := &core.CompilerOptions{} projectA := host.Project(contentmapper.ProjectSpec{ @@ -1080,7 +1076,7 @@ func TestProjectMethodsAfterHostClose(t *testing.T) { mapperProcess := &recordingMapper{dynamicConfig: true} host := contentmapper.NewHost(t.Context(), &fakeSpawner{handler: mapperProcess}, locale.Default) mapper := &contentmapper.Mapper{ - Manifest: contentmapper.Manifest{Name: "dynamic", Version: "1.0.0", Exec: []string{"mapper"}, DynamicConfig: true}, + Name: "dynamic", Version: "1.0.0", Exec: []string{"mapper"}, DynamicConfig: true, } project := host.Project(contentmapper.ProjectSpec{ ConfigFileName: "/repo/tsconfig.json", @@ -1120,8 +1116,8 @@ func TestProjectRejectsRelativeWatchedFiles(t *testing.T) { defer host.Close() projectMapper := &contentmapper.Mapper{ - Definition: contentmapper.Definition{Package: "dynamic"}, - Manifest: contentmapper.Manifest{Name: "dynamic", Version: "1.0.0", Exec: []string{"mapper"}, DynamicConfig: true}, + Package: "dynamic", + Name: "dynamic", Version: "1.0.0", Exec: []string{"mapper"}, DynamicConfig: true, } project := host.Project(contentmapper.ProjectSpec{ ConfigFileName: "/repo/tsconfig.json", @@ -1144,8 +1140,8 @@ func TestDynamicProjectRequiresConfigIdentity(t *testing.T) { defer host.Close() projectMapper := &contentmapper.Mapper{ - Definition: contentmapper.Definition{Package: "dynamic"}, - Manifest: contentmapper.Manifest{Name: "dynamic", Version: "1.0.0", Exec: []string{"mapper"}, DynamicConfig: true}, + Package: "dynamic", + Name: "dynamic", Version: "1.0.0", Exec: []string{"mapper"}, DynamicConfig: true, } project := host.Project(contentmapper.ProjectSpec{ ConfigFileName: "/repo/tsconfig.json", @@ -1175,7 +1171,7 @@ func TestStaticMapperRejectsDynamicProjectResponseFields(t *testing.T) { t.Parallel() host := contentmapper.NewHost(t.Context(), &fakeSpawner{handler: test.mapper}, locale.Default) defer host.Close() - projectMapper := &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: "static", Version: "1.0.0", Exec: []string{"mapper"}}} + projectMapper := &contentmapper.Mapper{Name: "static", Version: "1.0.0", Exec: []string{"mapper"}} project := host.Project(contentmapper.ProjectSpec{ ConfigFileName: "/repo/tsconfig.json", Mappers: []*contentmapper.Mapper{projectMapper}, @@ -1201,7 +1197,7 @@ func TestProjectRejectsInvalidOptionDiagnosticPath(t *testing.T) { }}} host := contentmapper.NewHost(t.Context(), &fakeSpawner{handler: mapperProcess}, locale.Default) defer host.Close() - projectMapper := &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: "mapper", Version: "1.0.0", Exec: []string{"mapper"}}} + projectMapper := &contentmapper.Mapper{Name: "mapper", Version: "1.0.0", Exec: []string{"mapper"}} project := host.Project(contentmapper.ProjectSpec{Mappers: []*contentmapper.Mapper{projectMapper}, CompilerOptions: &core.CompilerOptions{}}) defer project.Close() _, err := project.Transform(projectMapper, contentmapper.Request{FileName: "/repo/file.ext", Content: "x"}) @@ -1224,7 +1220,7 @@ func TestRunnerForwardsProjectOptions(t *testing.T) { r := contentmapper.NewHost(t.Context(), &fakeSpawner{handler: mapper}, diagnosticLocale) defer r.Close() - mapperDefinition := &contentmapper.Mapper{Definition: contentmapper.Definition{Options: []byte(`{"strictTemplates":true}`)}, Manifest: contentmapper.Manifest{Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}, CompilerOptions: []string{"target", "jsx"}}} + mapperDefinition := &contentmapper.Mapper{Options: []byte(`{"strictTemplates":true}`), Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}, CompilerOptions: []string{"target", "jsx"}} compilerOptions := &core.CompilerOptions{Target: core.ScriptTargetES2020, Strict: core.TSTrue} project := r.Project(contentmapper.ProjectSpec{Mappers: []*contentmapper.Mapper{mapperDefinition}, CompilerOptions: compilerOptions}) defer project.Close() @@ -1255,7 +1251,7 @@ func TestHostSetLocaleRestartsMapper(t *testing.T) { r := contentmapper.NewHost(t.Context(), spawner, locale.Default) defer r.Close() - definition := &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}}} + definition := &contentmapper.Mapper{Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}} release := r.Acquire([]*contentmapper.Mapper{definition}) defer release() @@ -1282,7 +1278,7 @@ func TestHostSetLocaleWaitsForTransform(t *testing.T) { spawner := &fakeSpawner{handler: mapper} r := contentmapper.NewHost(t.Context(), spawner, locale.Default) defer r.Close() - definition := &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}}} + definition := &contentmapper.Mapper{Name: "vue", Version: "1.0.0", Exec: []string{"vue-mapper"}} transformDone := make(chan error) go func() { diff --git a/tsc/internal/contentmapper/transform_test.go b/tsc/internal/contentmapper/transform_test.go index e902cfb112bc6..a961cf70d7229 100644 --- a/tsc/internal/contentmapper/transform_test.go +++ b/tsc/internal/contentmapper/transform_test.go @@ -30,7 +30,7 @@ func TestParseResultSupplementalFileExtensions(t *testing.T) { files, err := contentmapper.ParseResult( ast.SourceFileParseOptions{FileName: "/component.astro", Path: "/component.astro"}, "", - &contentmapper.Mapper{Definition: contentmapper.Definition{Extensions: []string{".astro"}}, Manifest: contentmapper.Manifest{Name: "mapper"}}, + &contentmapper.Mapper{Extensions: []string{".astro"}, Name: "mapper"}, "transform-identity", result, ) @@ -68,7 +68,7 @@ func TestParseResultAllowsSupplementalModules(t *testing.T) { files, err := contentmapper.ParseResult( ast.SourceFileParseOptions{FileName: "/component.astro", Path: "/component.astro"}, "", - &contentmapper.Mapper{Definition: contentmapper.Definition{Extensions: []string{".astro"}}, Manifest: contentmapper.Manifest{Name: "mapper"}}, + &contentmapper.Mapper{Extensions: []string{".astro"}, Name: "mapper"}, "", contentmapper.Result{ Text: "export {};", @@ -91,7 +91,7 @@ func TestParseResultDoesNotLeakCanonicalModuleForcingToSupplementals(t *testing. files, err := contentmapper.ParseResult( ast.SourceFileParseOptions{FileName: "/component.astro", Path: "/component.astro"}, "", - &contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: "mapper"}}, + &contentmapper.Mapper{Name: "mapper"}, "", contentmapper.Result{ Text: "const canonical = 1;", diff --git a/tsc/internal/execute/incremental/buildinfo_contentmapper_test.go b/tsc/internal/execute/incremental/buildinfo_contentmapper_test.go index bd2ae47240384..9a7229041aefd 100644 --- a/tsc/internal/execute/incremental/buildinfo_contentmapper_test.go +++ b/tsc/internal/execute/incremental/buildinfo_contentmapper_test.go @@ -25,24 +25,24 @@ func configWithMappers(mappers ...*contentmapper.Mapper) *tsoptions.ParsedComman func TestStaticContentMapperTransformIdentity(t *testing.T) { t.Parallel() - assert.Equal(t, (&contentmapper.Mapper{Manifest: contentmapper.Manifest{Name: "vue", Version: "2.0.0"}}).Identity(), "vue@2.0.0") - assert.Equal(t, (&contentmapper.Mapper{Definition: contentmapper.Definition{Package: "anon"}}).Identity(), "") + assert.Equal(t, (&contentmapper.Mapper{Name: "vue", Version: "2.0.0"}).Identity(), "vue@2.0.0") + assert.Equal(t, (&contentmapper.Mapper{Package: "anon"}).Identity(), "") jsxMapper := &contentmapper.Mapper{ - Definition: contentmapper.Definition{Package: "jsx"}, - Manifest: contentmapper.Manifest{Name: "jsx", Version: "1.0.0", CompilerOptions: []string{"jsx"}}, + Package: "jsx", + Name: "jsx", Version: "1.0.0", CompilerOptions: []string{"jsx"}, } jsxPreserveIdentity := jsxMapper.TransformIdentity(&core.CompilerOptions{Jsx: core.JsxEmitPreserve}) jsxReactIdentity := jsxMapper.TransformIdentity(&core.CompilerOptions{Jsx: core.JsxEmitReact}) assert.Assert(t, jsxPreserveIdentity != jsxReactIdentity) optionsA := &contentmapper.Mapper{ - Definition: contentmapper.Definition{Package: "vue", Options: []byte(`{"mode":"a"}`)}, - Manifest: contentmapper.Manifest{Name: "vue", Version: "1.0.0"}, + Package: "vue", Options: []byte(`{"mode":"a"}`), + Name: "vue", Version: "1.0.0", } optionsB := &contentmapper.Mapper{ - Definition: contentmapper.Definition{Package: "vue", Options: []byte(`{"mode":"b"}`)}, - Manifest: contentmapper.Manifest{Name: "vue", Version: "1.0.0"}, + Package: "vue", Options: []byte(`{"mode":"b"}`), + Name: "vue", Version: "1.0.0", } assert.Assert(t, optionsA.TransformIdentity(&core.CompilerOptions{}) != optionsB.TransformIdentity(&core.CompilerOptions{})) } @@ -78,8 +78,8 @@ func (p fakeContentMapperProject) Close() error { return nil } func TestDynamicContentMapperIdentities(t *testing.T) { t.Parallel() config := configWithMappers(&contentmapper.Mapper{ - Definition: contentmapper.Definition{Package: "dynamic"}, - Manifest: contentmapper.Manifest{Name: "dynamic", Version: "1.0.0", DynamicConfig: true}, + Package: "dynamic", + Name: "dynamic", Version: "1.0.0", DynamicConfig: true, }) project := fakeContentMapperProject{identities: []string{"dynamic@1.0.0:opaque"}} identities, err := incremental.ContentMapperIdentities(project) @@ -114,7 +114,7 @@ func TestReadBuildInfoProgramContentMapperIdentityMismatch(t *testing.T) { FileNames: []string{"/src/a.ts"}, ContentMapperIdentities: []string{"vue@1.0.0"}, } - config := configWithMappers(&contentmapper.Mapper{Definition: contentmapper.Definition{Package: "vue", Extensions: []string{".vue"}}, Manifest: contentmapper.Manifest{Name: "vue", Version: "2.0.0"}}) + config := configWithMappers(&contentmapper.Mapper{Package: "vue", Extensions: []string{".vue"}, Name: "vue", Version: "2.0.0"}) project := fakeContentMapperProject{identities: []string{"vue@2.0.0:current"}} host := compiler.NewCompilerHost("/", vfstest.FromMap[any](nil, true), "", nil, nil, project) diff --git a/tsc/internal/execute/tsc/diagnostics.go b/tsc/internal/execute/tsc/diagnostics.go index c4fa7b5ba6f41..f9f5033723439 100644 --- a/tsc/internal/execute/tsc/diagnostics.go +++ b/tsc/internal/execute/tsc/diagnostics.go @@ -9,17 +9,14 @@ import ( "github.com/microsoft/TypeScript/tsc/internal/core" "github.com/microsoft/TypeScript/tsc/internal/diagnosticwriter" "github.com/microsoft/TypeScript/tsc/internal/locale" - "github.com/microsoft/TypeScript/tsc/internal/tspath" ) func getFormatOptsOfSys(sys System, locale locale.Locale) *diagnosticwriter.FormattingOptions { return &diagnosticwriter.FormattingOptions{ - NewLine: "\n", - ComparePathsOptions: tspath.ComparePathsOptions{ - CurrentDirectory: sys.GetCurrentDirectory(), - UseCaseSensitiveFileNames: sys.FS().UseCaseSensitiveFileNames(), - }, - Locale: locale, + NewLine: "\n", + CurrentDirectory: sys.GetCurrentDirectory(), + UseCaseSensitiveFileNames: sys.FS().UseCaseSensitiveFileNames(), + Locale: locale, } } diff --git a/tsc/internal/format/api_test.go b/tsc/internal/format/api_test.go index d42df56296710..d393f28961ff6 100644 --- a/tsc/internal/format/api_test.go +++ b/tsc/internal/format/api_test.go @@ -40,15 +40,13 @@ func TestFormat(t *testing.T) { t.Run("format checker.ts", func(t *testing.T) { t.Parallel() ctx := format.WithFormatCodeSettings(t.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - BaseIndentSize: 4, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSTrue, - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 4, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSTrue, + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, InsertSpaceBeforeTypeAnnotation: core.TSTrue, }, "\n") filePath := filepath.Join(repo.TestDataPath(), "fixtures/compiler/checker.ts") @@ -68,15 +66,13 @@ func TestFormat(t *testing.T) { func BenchmarkFormat(b *testing.B) { ctx := format.WithFormatCodeSettings(b.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - BaseIndentSize: 4, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSTrue, - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 4, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSTrue, + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, InsertSpaceBeforeTypeAnnotation: core.TSTrue, }, "\n") filePath := filepath.Join(repo.TestDataPath(), "fixtures/compiler/checker.ts") diff --git a/tsc/internal/format/comment_test.go b/tsc/internal/format/comment_test.go index b8162975f298d..33cbce0a4f059 100644 --- a/tsc/internal/format/comment_test.go +++ b/tsc/internal/format/comment_test.go @@ -18,15 +18,13 @@ func TestCommentFormatting(t *testing.T) { t.Run("format comment issue reproduction", func(t *testing.T) { t.Parallel() ctx := format.WithFormatCodeSettings(t.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - BaseIndentSize: 4, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSTrue, - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 4, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSTrue, + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, InsertSpaceBeforeTypeAnnotation: core.TSTrue, }, "\n") @@ -69,15 +67,13 @@ func TestCommentFormatting(t *testing.T) { t.Run("format JSDoc with tab indentation", func(t *testing.T) { t.Parallel() ctx := format.WithFormatCodeSettings(t.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - BaseIndentSize: 0, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSFalse, // Use tabs - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSFalse, // Use tabs + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, InsertSpaceBeforeTypeAnnotation: core.TSTrue, }, "\n") @@ -106,15 +102,13 @@ func TestCommentFormatting(t *testing.T) { t.Run("format comment inside multi-line argument list", func(t *testing.T) { t.Parallel() ctx := format.WithFormatCodeSettings(t.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - BaseIndentSize: 0, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSFalse, // Use tabs - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSFalse, // Use tabs + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, InsertSpaceBeforeTypeAnnotation: core.TSTrue, }, "\n") @@ -139,15 +133,13 @@ func TestCommentFormatting(t *testing.T) { t.Run("format comment in chained method calls", func(t *testing.T) { t.Parallel() ctx := format.WithFormatCodeSettings(t.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - BaseIndentSize: 0, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSFalse, // Use tabs - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSFalse, // Use tabs + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, InsertSpaceBeforeTypeAnnotation: core.TSTrue, }, "\n") @@ -173,15 +165,13 @@ func TestCommentFormatting(t *testing.T) { t.Run("format chained method call with comment (issue #1928)", func(t *testing.T) { t.Parallel() ctx := format.WithFormatCodeSettings(t.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - BaseIndentSize: 0, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSFalse, // Use tabs - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSFalse, // Use tabs + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, InsertSpaceBeforeTypeAnnotation: core.TSTrue, }, "\n") @@ -206,15 +196,13 @@ func TestCommentFormatting(t *testing.T) { t.Run("multiline comment inside block that opens on first line (issue #2649)", func(t *testing.T) { t.Parallel() ctx := format.WithFormatCodeSettings(t.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - BaseIndentSize: 0, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSFalse, - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSFalse, + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, }, "\n") originalText := `document.addEventListener('DOMContentLoaded', () => { @@ -235,15 +223,13 @@ func TestCommentFormatting(t *testing.T) { t.Run("single-line comment inside block that opens on first line (issue #2649)", func(t *testing.T) { t.Parallel() ctx := format.WithFormatCodeSettings(t.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - BaseIndentSize: 0, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSFalse, - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSFalse, + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, }, "\n") originalText := `document.addEventListener('DOMContentLoaded', () => { @@ -268,15 +254,13 @@ func TestFormatSelectionPreservesComments(t *testing.T) { t.Run("format selection should not delete block comment when selection ends inside comment", func(t *testing.T) { t.Parallel() ctx := format.WithFormatCodeSettings(t.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - BaseIndentSize: 0, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSTrue, - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSTrue, + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, }, "\n") // Reproduce: const test/* comment */=5; @@ -303,15 +287,13 @@ func TestFormatSelectionPreservesComments(t *testing.T) { t.Run("format selection should not delete block comment when selection starts inside comment", func(t *testing.T) { t.Parallel() ctx := format.WithFormatCodeSettings(t.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - BaseIndentSize: 0, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSTrue, - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSTrue, + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, }, "\n") originalText := `const test/* comment */=5;` @@ -335,15 +317,13 @@ func TestFormatSelectionPreservesComments(t *testing.T) { t.Run("full document format should preserve block comment and add spaces", func(t *testing.T) { t.Parallel() ctx := format.WithFormatCodeSettings(t.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - BaseIndentSize: 0, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSTrue, - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSTrue, + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, InsertSpaceBeforeAndAfterBinaryOperators: core.TSTrue, }, "\n") @@ -368,15 +348,13 @@ func TestSliceBoundsPanic(t *testing.T) { t.Run("format code with trailing semicolon should not panic", func(t *testing.T) { t.Parallel() ctx := format.WithFormatCodeSettings(t.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - BaseIndentSize: 4, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSTrue, - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 4, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSTrue, + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, InsertSpaceBeforeTypeAnnotation: core.TSTrue, }, "\n") diff --git a/tsc/internal/format/format_test.go b/tsc/internal/format/format_test.go index 2ee70877255c7..6d8532010d8d6 100644 --- a/tsc/internal/format/format_test.go +++ b/tsc/internal/format/format_test.go @@ -33,14 +33,12 @@ func TestFormatNoTrailingSpace(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Parallel() ctx := format.WithFormatCodeSettings(t.Context(), lsutil.FormatCodeSettings{ - EditorSettings: lsutil.EditorSettings{ - TabSize: 4, - IndentSize: 4, - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSTrue, - IndentStyle: lsutil.IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, + TabSize: 4, + IndentSize: 4, + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSTrue, + IndentStyle: lsutil.IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, }, "\n") sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ FileName: "/test.ts", diff --git a/tsc/internal/fourslash/test_parser.go b/tsc/internal/fourslash/test_parser.go index 18e59049781dd..4acc853bf01cf 100644 --- a/tsc/internal/fourslash/test_parser.go +++ b/tsc/internal/fourslash/test_parser.go @@ -285,12 +285,10 @@ func parseFileContent(fileName string, content string, fileOptions map[string]st if previousCharacter == '[' && currentCharacter == '|' { // found a range start openRanges = append(openRanges, rangeLocationInformation{ - locationInformation: locationInformation{ - position: (i - 1) - difference, - sourcePosition: i - 1, - sourceLine: line, - sourceColumn: column, - }, + position: (i - 1) - difference, + sourcePosition: i - 1, + sourceLine: line, + sourceColumn: column, }) // copy all text up to marker position flush(i - 1) diff --git a/tsc/internal/ls/autoimport/extract.go b/tsc/internal/ls/autoimport/extract.go index 31ba6a2c7be07..c1a57f1af1749 100644 --- a/tsc/internal/ls/autoimport/extract.go +++ b/tsc/internal/ls/autoimport/extract.go @@ -264,10 +264,8 @@ func (e *symbolExtractor) createExport(symbol *ast.Symbol, moduleID ModuleID, mo } export := &Export{ - ExportID: ExportID{ - ExportName: symbol.Name, - ModuleID: moduleID, - }, + ExportName: symbol.Name, + ModuleID: moduleID, ModuleFileName: moduleFileName, Syntax: syntax, Flags: symbol.CombinedLocalAndExportSymbolFlags(), diff --git a/tsc/internal/ls/autoimport/registry_test.go b/tsc/internal/ls/autoimport/registry_test.go index a9b5b1349fd48..54b7af4102ac1 100644 --- a/tsc/internal/ls/autoimport/registry_test.go +++ b/tsc/internal/ls/autoimport/registry_test.go @@ -189,14 +189,12 @@ export const bar = 2;`, t.Run("node_modules buckets get deleted when no open files can reference them", func(t *testing.T) { t.Parallel() fixture := autoimporttestutil.SetupMonorepoLifecycleSession(t, autoimporttestutil.MonorepoSetupConfig{ - Root: monorepoProjectRoot, - MonorepoPackageTemplate: autoimporttestutil.MonorepoPackageTemplate{ - Name: "monorepo", - NodeModuleNames: []string{"pkg-root"}, - }, + Root: monorepoProjectRoot, + Name: "monorepo", + NodeModuleNames: []string{"pkg-root"}, Packages: []autoimporttestutil.MonorepoPackageConfig{ - {FileCount: 1, MonorepoPackageTemplate: autoimporttestutil.MonorepoPackageTemplate{Name: "package-a", NodeModuleNames: []string{"pkg-a"}}}, - {FileCount: 1, MonorepoPackageTemplate: autoimporttestutil.MonorepoPackageTemplate{Name: "package-b", NodeModuleNames: []string{"pkg-b"}}}, + {FileCount: 1, Name: "package-a", NodeModuleNames: []string{"pkg-a"}}, + {FileCount: 1, Name: "package-b", NodeModuleNames: []string{"pkg-b"}}, }, }) session := fixture.Session() @@ -358,19 +356,15 @@ export const bar = 2;`, packageAIndex := tspath.CombinePaths(packageADir, "index.js") fixture := autoimporttestutil.SetupMonorepoLifecycleSession(t, autoimporttestutil.MonorepoSetupConfig{ - Root: monorepoRoot, - MonorepoPackageTemplate: autoimporttestutil.MonorepoPackageTemplate{ - Name: "monorepo", - NodeModuleNames: []string{"pkg1", "pkg2", "pkg3"}, - DependencyNames: []string{"pkg1"}, - }, + Root: monorepoRoot, + Name: "monorepo", + NodeModuleNames: []string{"pkg1", "pkg2", "pkg3"}, + DependencyNames: []string{"pkg1"}, Packages: []autoimporttestutil.MonorepoPackageConfig{ { - FileCount: 0, - MonorepoPackageTemplate: autoimporttestutil.MonorepoPackageTemplate{ - Name: "a", - DependencyNames: []string{"pkg1", "pkg2"}, - }, + FileCount: 0, + Name: "a", + DependencyNames: []string{"pkg1", "pkg2"}, }, }, ExtraFiles: []autoimporttestutil.TextFileSpec{ @@ -434,29 +428,23 @@ export const bar = 2;`, fixture := autoimporttestutil.SetupMonorepoLifecycleSession(t, autoimporttestutil.MonorepoSetupConfig{ Root: monorepoRoot, - MonorepoPackageTemplate: autoimporttestutil.MonorepoPackageTemplate{ - Name: "monorepo", - // Both pkg-listed and pkg-unlisted exist in node_modules - NodeModuleNames: []string{"pkg-listed", "pkg-unlisted"}, - // But only pkg-listed is in the root package.json dependencies - DependencyNames: []string{"pkg-listed"}, - }, + Name: "monorepo", + // Both pkg-listed and pkg-unlisted exist in node_modules + NodeModuleNames: []string{"pkg-listed", "pkg-unlisted"}, + // But only pkg-listed is in the root package.json dependencies + DependencyNames: []string{"pkg-listed"}, Packages: []autoimporttestutil.MonorepoPackageConfig{ { FileCount: 0, - MonorepoPackageTemplate: autoimporttestutil.MonorepoPackageTemplate{ - Name: "a", - // package-a only lists pkg-listed in its package.json - DependencyNames: []string{"pkg-listed"}, - }, + Name: "a", + // package-a only lists pkg-listed in its package.json + DependencyNames: []string{"pkg-listed"}, }, { FileCount: 0, - MonorepoPackageTemplate: autoimporttestutil.MonorepoPackageTemplate{ - Name: "b", - // package-b also only lists pkg-listed in its package.json - DependencyNames: []string{"pkg-listed"}, - }, + Name: "b", + // package-b also only lists pkg-listed in its package.json + DependencyNames: []string{"pkg-listed"}, }, }, ExtraFiles: []autoimporttestutil.TextFileSpec{ diff --git a/tsc/internal/ls/findallreferences.go b/tsc/internal/ls/findallreferences.go index 84f20ad34f922..f893b61de8a4e 100644 --- a/tsc/internal/ls/findallreferences.go +++ b/tsc/internal/ls/findallreferences.go @@ -520,10 +520,8 @@ func (l *LanguageService) getNonLocalDefinition(ctx context.Context, entry *Symb continue } return &nonLocalDefinition{ - position: position{ - uri: lsconv.FileNameToDocumentURI(fileName), - pos: lspPosition, - }, + uri: lsconv.FileNameToDocumentURI(fileName), + pos: lspPosition, GetSourcePosition: sync.OnceValue(func() lsproto.HasTextDocumentPosition { mapped := l.tryGetSourcePosition(fileName, startPos) if mapped != nil { diff --git a/tsc/internal/ls/lsconv/converters.go b/tsc/internal/ls/lsconv/converters.go index 23eb9036206ee..bdb724f7667a4 100644 --- a/tsc/internal/ls/lsconv/converters.go +++ b/tsc/internal/ls/lsconv/converters.go @@ -154,13 +154,11 @@ func FromLSPRangeIntersectingForSourceFile(c *Converters, file *ast.SourceFile, if spans == nil { result = append(result, MappedSpan[*ast.SourceFile]{ Script: script, - MappedSpan: spanmap.MappedSpan{ - Span: core.NewTextRange( - int(c.lineAndCharacterToPosition(script, textRange.Start)), - int(c.lineAndCharacterToPosition(script, textRange.End)), - ), - Fidelity: spanmap.FidelityExact, - }, + Span: core.NewTextRange( + int(c.lineAndCharacterToPosition(script, textRange.Start)), + int(c.lineAndCharacterToPosition(script, textRange.End)), + ), + Fidelity: spanmap.FidelityExact, }) continue } diff --git a/tsc/internal/ls/lsutil/formatcodeoptions.go b/tsc/internal/ls/lsutil/formatcodeoptions.go index d63d3b489af41..73c8a899a63a1 100644 --- a/tsc/internal/ls/lsutil/formatcodeoptions.go +++ b/tsc/internal/ls/lsutil/formatcodeoptions.go @@ -113,19 +113,17 @@ func (settings FormatCodeSettings) ToLSFormatOptions() *lsproto.FormattingOption func GetDefaultFormatCodeSettings() FormatCodeSettings { return FormatCodeSettings{ - EditorSettings: EditorSettings{ - IndentSize: printer.GetDefaultIndentSize(), - TabSize: printer.GetDefaultIndentSize(), - NewLineCharacter: "\n", - ConvertTabsToSpaces: core.TSTrue, - IndentStyle: IndentStyleSmart, - TrimTrailingWhitespace: core.TSTrue, - }, - InsertSpaceAfterConstructor: core.TSFalse, - InsertSpaceAfterCommaDelimiter: core.TSTrue, - InsertSpaceAfterSemicolonInForStatements: core.TSTrue, - InsertSpaceBeforeAndAfterBinaryOperators: core.TSTrue, - InsertSpaceAfterKeywordsInControlFlowStatements: core.TSTrue, + IndentSize: printer.GetDefaultIndentSize(), + TabSize: printer.GetDefaultIndentSize(), + NewLineCharacter: "\n", + ConvertTabsToSpaces: core.TSTrue, + IndentStyle: IndentStyleSmart, + TrimTrailingWhitespace: core.TSTrue, + InsertSpaceAfterConstructor: core.TSFalse, + InsertSpaceAfterCommaDelimiter: core.TSTrue, + InsertSpaceAfterSemicolonInForStatements: core.TSTrue, + InsertSpaceBeforeAndAfterBinaryOperators: core.TSTrue, + InsertSpaceAfterKeywordsInControlFlowStatements: core.TSTrue, InsertSpaceAfterFunctionKeywordForAnonymousFunctions: core.TSFalse, InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: core.TSFalse, InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: core.TSFalse, diff --git a/tsc/internal/lsp/server.go b/tsc/internal/lsp/server.go index 9b3a4fccc7ae3..928f6e516c02d 100644 --- a/tsc/internal/lsp/server.go +++ b/tsc/internal/lsp/server.go @@ -2504,15 +2504,13 @@ func parseContentMapperContributions(values []*lsproto.ContentMapperContribution } } mapper := &contentmapper.Mapper{ - Definition: contentmapper.Definition{Package: identity, Extensions: validExtensions, Options: options}, - Manifest: contentmapper.Manifest{ - Name: manifest.Name, - Version: valueOrZero(manifest.Version), - Exec: slices.Clone(manifest.Exec), - CompilerOptions: slices.Clone(valueOrZero(manifest.CompilerOptions)), - DynamicConfig: valueOrZero(manifest.DynamicConfig), - }, - ContributionID: identity, + Package: identity, Extensions: validExtensions, Options: options, + Name: manifest.Name, + Version: valueOrZero(manifest.Version), + Exec: slices.Clone(manifest.Exec), + CompilerOptions: slices.Clone(valueOrZero(manifest.CompilerOptions)), + DynamicConfig: valueOrZero(manifest.DynamicConfig), + ContributionID: identity, } if manifest.Cwd != nil { if !tspath.PathIsAbsolute(*manifest.Cwd) { diff --git a/tsc/internal/modulespecifiers/specifiers_test.go b/tsc/internal/modulespecifiers/specifiers_test.go index 35269a9df76c9..4905febfa31af 100644 --- a/tsc/internal/modulespecifiers/specifiers_test.go +++ b/tsc/internal/modulespecifiers/specifiers_test.go @@ -328,10 +328,8 @@ func TestTryGetModuleNameFromExportsOrImports(t *testing.T) { "/pkg", "./src/things/*", packagejson.ExportsOrImports{ - JSONValue: packagejson.JSONValue{ - Type: packagejson.JSONValueTypeString, - Value: "./src/things/*/index.js", - }, + Type: packagejson.JSONValueTypeString, + Value: "./src/things/*/index.js", }, []string{}, MatchingModePattern, diff --git a/tsc/internal/printer/changetrackerwriter.go b/tsc/internal/printer/changetrackerwriter.go index aebc68c95a04e..9e508f9631337 100644 --- a/tsc/internal/printer/changetrackerwriter.go +++ b/tsc/internal/printer/changetrackerwriter.go @@ -27,7 +27,7 @@ func NewChangeTrackerWriter(newline string, indentSize int) *ChangeTrackerWriter indentSize = defaultIndentSize } ctw := &ChangeTrackerWriter{ - textWriter: textWriter{newLine: newline, indentSize: indentSize}, + newLine: newline, indentSize: indentSize, lastNonTriviaPosition: 0, pos: map[triviaPositionKey]int{}, end: map[triviaPositionKey]int{}, diff --git a/tsc/internal/project/api.go b/tsc/internal/project/api.go index 284897f29c147..182b65ef6a9c7 100644 --- a/tsc/internal/project/api.go +++ b/tsc/internal/project/api.go @@ -61,9 +61,7 @@ func (s *Session) APIUpdateTemporary(ctx context.Context, baseSnapshot *Snapshot newSnapshot := baseSnapshot.Clone(ctx, SnapshotChange{ fileChanges: fileChanges, - ResourceRequest: ResourceRequest{ - Documents: []lsproto.DocumentUri{uri}, - }, + Documents: []lsproto.DocumentUri{uri}, }, overlays, s) return newSnapshot, nil } diff --git a/tsc/internal/project/contentmapper_test.go b/tsc/internal/project/contentmapper_test.go index feda9d756dcd4..a37f1438b45a7 100644 --- a/tsc/internal/project/contentmapper_test.go +++ b/tsc/internal/project/contentmapper_test.go @@ -662,8 +662,8 @@ func TestContentMapperOpenFileExcludedByConfigChange(t *testing.T) { boxURI := lsproto.DocumentUri("file:///home/project/src/app.box") session.SetContentMapperContributions(ctx, project.ContentMapperContributions{ Mappers: []*contentmapper.Mapper{{ - Definition: contentmapper.Definition{Package: "test.extension", Extensions: []string{".box"}}, - Manifest: contentmapper.Manifest{Name: "mapper", Version: "1.0.0", Exec: []string{contentmappertest.TransformingMapper}, CompilerOptions: contentmappertest.DeclaredOptions}, + Package: "test.extension", Extensions: []string{".box"}, + Name: "mapper", Version: "1.0.0", Exec: []string{contentmappertest.TransformingMapper}, CompilerOptions: contentmappertest.DeclaredOptions, PackageDirectory: "/home/project", ContributionID: "test.extension[0]", }}, @@ -851,8 +851,8 @@ func TestContentMapperInferredProjectUsesExtensionContributions(t *testing.T) { assert.ErrorContains(t, err, "no project found", "configured mapper must not leak into inferred projects") session.SetContentMapperContributions(ctx, project.ContentMapperContributions{ Mappers: []*contentmapper.Mapper{{ - Definition: contentmapper.Definition{Package: "test.extension", Extensions: []string{".box"}}, - Manifest: contentmapper.Manifest{Name: "mapper", Version: "1.0.0", Exec: []string{contentmappertest.TransformingMapper}, CompilerOptions: contentmappertest.DeclaredOptions}, + Package: "test.extension", Extensions: []string{".box"}, + Name: "mapper", Version: "1.0.0", Exec: []string{contentmappertest.TransformingMapper}, CompilerOptions: contentmappertest.DeclaredOptions, PackageDirectory: "/home", ContributionID: "test.extension[0]", }}, @@ -905,8 +905,8 @@ func TestContentMapperInferredProjectSurvivesTypingsInstall(t *testing.T) { ctx := context.Background() session.SetContentMapperContributions(ctx, project.ContentMapperContributions{ Mappers: []*contentmapper.Mapper{{ - Definition: contentmapper.Definition{Package: "test.extension", Extensions: []string{".box"}}, - Manifest: contentmapper.Manifest{Name: "mapper", Version: "1.0.0", Exec: []string{contentmappertest.TransformingMapper}, CompilerOptions: contentmappertest.DeclaredOptions}, + Package: "test.extension", Extensions: []string{".box"}, + Name: "mapper", Version: "1.0.0", Exec: []string{contentmappertest.TransformingMapper}, CompilerOptions: contentmappertest.DeclaredOptions, PackageDirectory: "/home", ContributionID: "test.extension[0]", }}, diff --git a/tsc/internal/project/dirty/map.go b/tsc/internal/project/dirty/map.go index e90d8b7130cb2..cc74ee62833b8 100644 --- a/tsc/internal/project/dirty/map.go +++ b/tsc/internal/project/dirty/map.go @@ -73,13 +73,11 @@ func (m *Map[K, V]) Get(key K) (*MapEntry[K, V], bool) { return nil, false } return &MapEntry[K, V]{ - m: m, - mapEntry: mapEntry[K, V]{ - key: key, - original: value, - value: value, - dirty: false, - }, + m: m, + key: key, + original: value, + value: value, + dirty: false, }, true } @@ -90,12 +88,10 @@ func (m *Map[K, V]) Get(key K) (*MapEntry[K, V], bool) { // exist in the base map, use `Change` instead. func (m *Map[K, V]) Add(key K, value V) { m.dirty[key] = &MapEntry[K, V]{ - m: m, - mapEntry: mapEntry[K, V]{ - key: key, - value: value, - dirty: true, - }, + m: m, + key: key, + value: value, + dirty: true, } } @@ -133,12 +129,13 @@ func (m *Map[K, V]) Range(fn func(*MapEntry[K, V]) bool) { if _, ok := seenInDirty[key]; ok { continue // already processed in dirty entries } - if !fn(&MapEntry[K, V]{m: m, mapEntry: mapEntry[K, V]{ + if !fn(&MapEntry[K, V]{ + m: m, key: key, original: value, value: value, dirty: false, - }}) { + }) { break } } diff --git a/tsc/internal/project/dirty/syncmap.go b/tsc/internal/project/dirty/syncmap.go index c57b17dafd05b..6d75259d935f6 100644 --- a/tsc/internal/project/dirty/syncmap.go +++ b/tsc/internal/project/dirty/syncmap.go @@ -212,14 +212,12 @@ func (m *SyncMap[K, V]) Load(key K) (*SyncMapEntry[K, V], bool) { } if val, ok := m.base[key]; ok { return &SyncMapEntry[K, V]{ - m: m, - mapEntry: mapEntry[K, V]{ - key: key, - original: val, - value: val, - dirty: false, - delete: false, - }, + m: m, + key: key, + original: val, + value: val, + dirty: false, + delete: false, }, true } return nil, false @@ -237,23 +235,19 @@ func (m *SyncMap[K, V]) LoadOrStore(key K, value V) (*SyncMapEntry[K, V], bool) return dirty, true } return &SyncMapEntry[K, V]{ - m: m, - mapEntry: mapEntry[K, V]{ - key: key, - original: baseValue, - value: baseValue, - dirty: false, - delete: false, - }, + m: m, + key: key, + original: baseValue, + value: baseValue, + dirty: false, + delete: false, }, true } entry, loaded := m.dirty.LoadOrStore(key, &SyncMapEntry[K, V]{ - m: m, - mapEntry: mapEntry[K, V]{ - key: key, - value: value, - dirty: true, - }, + m: m, + key: key, + value: value, + dirty: true, }) if loaded { entry.mu.Lock() @@ -267,12 +261,10 @@ func (m *SyncMap[K, V]) LoadOrStore(key K, value V) (*SyncMapEntry[K, V], bool) func (m *SyncMap[K, V]) Delete(key K) { entry, loaded := m.dirty.LoadOrStore(key, &SyncMapEntry[K, V]{ - m: m, - mapEntry: mapEntry[K, V]{ - key: key, - original: m.base[key], - delete: true, - }, + m: m, + key: key, + original: m.base[key], + delete: true, }) if loaded { entry.Delete() @@ -295,12 +287,13 @@ func (m *SyncMap[K, V]) Range(fn func(*SyncMapEntry[K, V]) bool) { if _, ok := seenInDirty[key]; ok { continue // already processed in dirty entries } - if !fn(&SyncMapEntry[K, V]{m: m, mapEntry: mapEntry[K, V]{ + if !fn(&SyncMapEntry[K, V]{ + m: m, key: key, original: value, value: value, dirty: false, - }}) { + }) { break } } diff --git a/tsc/internal/project/logging/logcollector.go b/tsc/internal/project/logging/logcollector.go index 0870c4e1f81e3..eebbe93ae0794 100644 --- a/tsc/internal/project/logging/logcollector.go +++ b/tsc/internal/project/logging/logcollector.go @@ -23,11 +23,9 @@ func (lc *logCollector) String() string { func NewTestLogger() LogCollector { var builder strings.Builder return &logCollector{ - logger: logger{ - writer: &builder, - prefix: func() string { - return formatTime(time.Unix(1349085672, 0)) - }, + writer: &builder, + prefix: func() string { + return formatTime(time.Unix(1349085672, 0)) }, builder: &builder, } diff --git a/tsc/internal/project/overlayfs.go b/tsc/internal/project/overlayfs.go index 476008cda21d3..e1da6edd1fb94 100644 --- a/tsc/internal/project/overlayfs.go +++ b/tsc/internal/project/overlayfs.go @@ -78,11 +78,9 @@ type diskFile struct { func newDiskFile(fileName string, content string) *diskFile { return &diskFile{ - fileBase: fileBase{ - fileName: fileName, - content: content, - hash: xxh3.HashString128(content), - }, + fileName: fileName, + content: content, + hash: xxh3.HashString128(content), } } @@ -107,11 +105,9 @@ func (f *diskFile) Kind() core.ScriptKind { func (f *diskFile) Clone() *diskFile { return &diskFile{ realpathPath: f.realpathPath, - fileBase: fileBase{ - fileName: f.fileName, - content: f.content, - hash: f.hash, - }, + fileName: f.fileName, + content: f.content, + hash: f.hash, } } @@ -126,13 +122,11 @@ type Overlay struct { func newOverlay(fileName string, content string, version int32, kind core.ScriptKind) *Overlay { return &Overlay{ - fileBase: fileBase{ - fileName: fileName, - content: content, - hash: xxh3.HashString128(content), - }, - version: version, - kind: kind, + fileName: fileName, + content: content, + hash: xxh3.HashString128(content), + version: version, + kind: kind, } } diff --git a/tsc/internal/project/refcountcache_test.go b/tsc/internal/project/refcountcache_test.go index 99e94063975b9..3026cca3493f2 100644 --- a/tsc/internal/project/refcountcache_test.go +++ b/tsc/internal/project/refcountcache_test.go @@ -21,7 +21,7 @@ import ( func TestContentMappedParseCacheBundleLifetime(t *testing.T) { t.Parallel() cache := NewContentMappedParseCache(RefCountCacheOptions{}) - key := ContentMappedParseCacheKey{SourceFileParseOptions: ast.SourceFileParseOptions{FileName: "/component.vue", Path: "/component.vue"}} + key := ContentMappedParseCacheKey{FileName: "/component.vue", Path: "/component.vue"} canonical := &ast.SourceFile{} supplemental := &ast.SourceFile{} produced := contentmapper.SourceFiles{Canonical: canonical, Supplemental: []*ast.SourceFile{supplemental}} @@ -463,10 +463,8 @@ func TestRefCountingCaches(t *testing.T) { baseSnapshot := session.Snapshot() extendedConfigPath := tspath.Path("/user/username/projects/myproject/tsconfig.base.json") clone := baseSnapshot.Clone(context.Background(), SnapshotChange{ - reason: UpdateReasonRequestedLanguageServiceProjectNotLoaded, - ResourceRequest: ResourceRequest{ - Documents: []lsproto.DocumentUri{uri}, - }, + reason: UpdateReasonRequestedLanguageServiceProjectNotLoaded, + Documents: []lsproto.DocumentUri{uri}, }, baseSnapshot.fs.overlays, session) project := clone.GetDefaultProject(uri) diff --git a/tsc/internal/project/session.go b/tsc/internal/project/session.go index d19fa70d16645..16d3e14ae2076 100644 --- a/tsc/internal/project/session.go +++ b/tsc/internal/project/session.go @@ -394,9 +394,7 @@ func (s *Session) DidOpenFile(ctx context.Context, uri lsproto.DocumentUri, vers s.UpdateSnapshot(ctx, overlays, SnapshotChange{ reason: UpdateReasonDidOpenFile, fileChanges: changes, - ResourceRequest: ResourceRequest{ - Documents: []lsproto.DocumentUri{uri}, - }, + Documents: []lsproto.DocumentUri{uri}, }) } @@ -416,9 +414,7 @@ func (s *Session) SetContentMapperContributions(ctx context.Context, contributio reason: UpdateReasonDidChangeContentMapperContributions, fileChanges: changes, contentMapperContributions: &contributions, - ResourceRequest: ResourceRequest{ - ConfiguredProjectDocuments: documentURIs, - }, + ConfiguredProjectDocuments: documentURIs, }) _ = s.updateContentMapperRegistrations(ctx, s.Snapshot()) } @@ -1368,11 +1364,9 @@ func (s *Session) GetSnapshotWithAutoImports(ctx context.Context, baseSnapshot * func (s *Session) cloneWithAutoImports(ctx context.Context, baseSnapshot *Snapshot, uri lsproto.DocumentUri, callerRef bool) *Snapshot { change := SnapshotChange{ - reason: UpdateReasonRequestedLanguageServiceWithAutoImports, - ResourceRequest: ResourceRequest{ - Documents: []lsproto.DocumentUri{uri}, - AutoImports: uri, - }, + reason: UpdateReasonRequestedLanguageServiceWithAutoImports, + Documents: []lsproto.DocumentUri{uri}, + AutoImports: uri, } newSnapshot := baseSnapshot.Clone(ctx, change, baseSnapshot.fs.overlays, s) if callerRef { @@ -2150,11 +2144,9 @@ func (s *Session) warmAutoImportCache(ctx context.Context, change SnapshotChange defer newSnapshot.Deref(s) warmChange := SnapshotChange{ - reason: UpdateReasonRequestedLanguageServiceWithAutoImports, - ResourceRequest: ResourceRequest{ - Documents: []lsproto.DocumentUri{changedFile}, - AutoImports: changedFile, - }, + reason: UpdateReasonRequestedLanguageServiceWithAutoImports, + Documents: []lsproto.DocumentUri{changedFile}, + AutoImports: changedFile, } clonedSnapshot := newSnapshot.Clone(warmCtx, warmChange, newSnapshot.fs.overlays, s) diff --git a/tsc/internal/project/snapshotfs.go b/tsc/internal/project/snapshotfs.go index 61fc7312977e1..994d2f4545818 100644 --- a/tsc/internal/project/snapshotfs.go +++ b/tsc/internal/project/snapshotfs.go @@ -342,7 +342,7 @@ func (s *snapshotFSBuilder) GetAccessibleEntries(path string) vfs.Entries { } func (s *snapshotFSBuilder) getDiskFile(fileName string, path tspath.Path, forceReload bool) FileHandle { - entry, loaded := s.diskFiles.LoadOrStore(path, &diskFile{fileBase: fileBase{fileName: fileName}, needsReload: true}) + entry, loaded := s.diskFiles.LoadOrStore(path, &diskFile{fileName: fileName, needsReload: true}) if entry != nil { if !loaded && strings.Contains(string(path), "/node_modules/") { s.recordRealpathAlias(entry, fileName, path) diff --git a/tsc/internal/testutil/autoimporttestutil/fixtures.go b/tsc/internal/testutil/autoimporttestutil/fixtures.go index 845080c5ee7dd..408c19418b9b3 100644 --- a/tsc/internal/testutil/autoimporttestutil/fixtures.go +++ b/tsc/internal/testutil/autoimporttestutil/fixtures.go @@ -366,7 +366,7 @@ func (r *projectRecord) toHandles() ProjectHandle { files := make([]ProjectFileHandle, len(r.sourceFiles)) for i, file := range r.sourceFiles { files[i] = ProjectFileHandle{ - FileHandle: FileHandle{fileName: file.FileName, content: file.Content}, + fileName: file.FileName, content: file.Content, exportIdentifier: file.ExportIdentifier, } } diff --git a/tsc/internal/testutil/contentmappertest/component.go b/tsc/internal/testutil/contentmappertest/component.go index 7da16c276f944..57ed38a5bccaf 100644 --- a/tsc/internal/testutil/contentmappertest/component.go +++ b/tsc/internal/testutil/contentmappertest/component.go @@ -27,7 +27,7 @@ func (componentHandler) HandleRequest(ctx context.Context, method string, params if err != nil { return nil, err } - return contentmapper.TransformResult{MappedOutput: contentmapper.MappedOutput{Text: text, Extension: ".ts", Mappings: mappings}}, nil + return contentmapper.TransformResult{Text: text, Extension: ".ts", Mappings: mappings}, nil default: return nil, fmt.Errorf("contentmappertest: unexpected method %q", method) } diff --git a/tsc/internal/testutil/contentmappertest/duplicate.go b/tsc/internal/testutil/contentmappertest/duplicate.go index 2ccd70b3fe3da..005fcf4e73cff 100644 --- a/tsc/internal/testutil/contentmappertest/duplicate.go +++ b/tsc/internal/testutil/contentmappertest/duplicate.go @@ -33,7 +33,7 @@ func (duplicateHandler) HandleRequest(ctx context.Context, method string, params if err != nil { return nil, err } - return contentmapper.TransformResult{MappedOutput: contentmapper.MappedOutput{Text: virtual, Extension: ".ts", Mappings: json.Value(mappings)}}, nil + return contentmapper.TransformResult{Text: virtual, Extension: ".ts", Mappings: json.Value(mappings)}, nil } if strings.Contains(p.FileName, "hover-concat") { virtual := "namespace A { export const " + p.Content + " = 1; }\nnamespace B { export const " + p.Content + " = \"text\"; }\n" @@ -46,7 +46,7 @@ func (duplicateHandler) HandleRequest(ctx context.Context, method string, params if err != nil { return nil, err } - return contentmapper.TransformResult{MappedOutput: contentmapper.MappedOutput{Text: virtual, Extension: ".ts", Mappings: json.Value(mappings)}}, nil + return contentmapper.TransformResult{Text: virtual, Extension: ".ts", Mappings: json.Value(mappings)}, nil } if strings.Contains(p.FileName, "signature-fallback") { virtual := "// " + p.Content + "\nfunction use(value: number): void {}\n" + p.Content + ";\n" @@ -59,7 +59,7 @@ func (duplicateHandler) HandleRequest(ctx context.Context, method string, params if err != nil { return nil, err } - return contentmapper.TransformResult{MappedOutput: contentmapper.MappedOutput{Text: virtual, Extension: ".ts", Mappings: json.Value(mappings)}}, nil + return contentmapper.TransformResult{Text: virtual, Extension: ".ts", Mappings: json.Value(mappings)}, nil } if strings.Contains(p.FileName, "rename-conflict") { virtual := "export const " + p.Content + " = 1;\nconst object = { " + p.Content + " };\n" + p.Content + ";\n" @@ -74,7 +74,7 @@ func (duplicateHandler) HandleRequest(ctx context.Context, method string, params if err != nil { return nil, err } - return contentmapper.TransformResult{MappedOutput: contentmapper.MappedOutput{Text: virtual, Extension: ".ts", Mappings: json.Value(mappings)}}, nil + return contentmapper.TransformResult{Text: virtual, Extension: ".ts", Mappings: json.Value(mappings)}, nil } virtual := "export const " + p.Content + " = 1;\n" + p.Content + ";\n" first := len("export const ") @@ -93,7 +93,7 @@ func (duplicateHandler) HandleRequest(ctx context.Context, method string, params if err != nil { return nil, err } - return contentmapper.TransformResult{MappedOutput: contentmapper.MappedOutput{Text: virtual, Extension: ".ts", Mappings: json.Value(mappings)}}, nil + return contentmapper.TransformResult{Text: virtual, Extension: ".ts", Mappings: json.Value(mappings)}, nil default: return nil, fmt.Errorf("contentmappertest: unexpected method %q", method) } diff --git a/tsc/internal/testutil/contentmappertest/editing.go b/tsc/internal/testutil/contentmappertest/editing.go index b3db5a3db234e..d295837a46bbe 100644 --- a/tsc/internal/testutil/contentmappertest/editing.go +++ b/tsc/internal/testutil/contentmappertest/editing.go @@ -96,12 +96,12 @@ func (prefixedSupplementalHandler) HandleRequest(ctx context.Context, method str return nil, err } return contentmapper.TransformResult{ - MappedOutput: contentmapper.MappedOutput{Text: p.Content[:thirdStart], Extension: ".ts", Mappings: json.Value(canonicalMappings)}, - Supplemental: []contentmapper.SupplementalOutput{{MappedOutput: contentmapper.MappedOutput{ + Text: p.Content[:thirdStart], Extension: ".ts", Mappings: json.Value(canonicalMappings), + Supplemental: []contentmapper.SupplementalOutput{{ Text: supplementalText, Extension: ".ts", Mappings: json.Value(mappings), - }}}, + }}, }, nil } mappings, err := spanmap.New(segments).Marshal() @@ -125,11 +125,11 @@ func (prefixedSupplementalHandler) HandleRequest(ctx context.Context, method str } return contentmapper.TransformResult{ MappedOutput: canonical, - Supplemental: []contentmapper.SupplementalOutput{{MappedOutput: contentmapper.MappedOutput{ + Supplemental: []contentmapper.SupplementalOutput{{ Text: supplementalText, Extension: ".ts", Mappings: json.Value(mappings), - }}}, + }}, }, nil default: return nil, fmt.Errorf("contentmappertest: unexpected method %q", method) @@ -147,7 +147,7 @@ func (unmappedFoldingHandler) HandleRequest(ctx context.Context, method string, if err != nil { return nil, err } - return contentmapper.TransformResult{MappedOutput: contentmapper.MappedOutput{ + return contentmapper.TransformResult{ Text: `import "a"; import "b"; /* @@ -156,7 +156,7 @@ import "b"; export {};`, Extension: ".ts", Mappings: json.Value(mappings), - }}, nil + }, nil default: return nil, fmt.Errorf("contentmappertest: unexpected method %q", method) } diff --git a/tsc/internal/testutil/contentmappertest/lisp.go b/tsc/internal/testutil/contentmappertest/lisp.go index 97f8c174987be..74bb3c3427f6f 100644 --- a/tsc/internal/testutil/contentmappertest/lisp.go +++ b/tsc/internal/testutil/contentmappertest/lisp.go @@ -33,11 +33,11 @@ func (lispHandler) HandleRequest(ctx context.Context, method string, params json if err != nil { return nil, err } - return contentmapper.TransformResult{MappedOutput: contentmapper.MappedOutput{ + return contentmapper.TransformResult{ Text: `add(1, 2, "oops");`, Extension: ".ts", Mappings: json.Value(mappings), - }}, nil + }, nil default: return nil, fmt.Errorf("contentmappertest: unexpected method %q", method) } diff --git a/tsc/internal/testutil/contentmappertest/mapper_test.go b/tsc/internal/testutil/contentmappertest/mapper_test.go index fbad19ddefb4d..537039314e04b 100644 --- a/tsc/internal/testutil/contentmappertest/mapper_test.go +++ b/tsc/internal/testutil/contentmappertest/mapper_test.go @@ -37,16 +37,12 @@ func (stdio) Close() error { return nil } func testMapper() *contentmapper.Mapper { return &contentmapper.Mapper{ - Definition: contentmapper.Definition{ - Package: contentmappertest.PackageName, - Extensions: []string{".box"}, - }, - Manifest: contentmapper.Manifest{ - Name: contentmappertest.PackageName, - Version: "1.0.0", - Exec: []string{contentmappertest.TransformingMapper}, - CompilerOptions: contentmappertest.DeclaredOptions, - }, + Package: contentmappertest.PackageName, + Extensions: []string{".box"}, + Name: contentmappertest.PackageName, + Version: "1.0.0", + Exec: []string{contentmappertest.TransformingMapper}, + CompilerOptions: contentmappertest.DeclaredOptions, PackageDirectory: "/node_modules/" + contentmappertest.PackageName, } } diff --git a/tsc/internal/testutil/contentmappertest/supplemental.go b/tsc/internal/testutil/contentmappertest/supplemental.go index 599ed258e8a7a..0d96334485bc8 100644 --- a/tsc/internal/testutil/contentmappertest/supplemental.go +++ b/tsc/internal/testutil/contentmappertest/supplemental.go @@ -24,7 +24,7 @@ func (supplementalHandler) HandleRequest(ctx context.Context, method string, par return nil, err } return contentmapper.TransformResult{ - MappedOutput: contentmapper.MappedOutput{Text: "export {};", Extension: ".ts"}, + Text: "export {};", Extension: ".ts", Supplemental: []contentmapper.SupplementalOutput{{MappedOutput: mappedOutput}}, }, nil default: diff --git a/tsc/internal/testutil/contentmappertest/supplemental_diagnostics.go b/tsc/internal/testutil/contentmappertest/supplemental_diagnostics.go index 6ba9b509501d8..43dcc8af625d1 100644 --- a/tsc/internal/testutil/contentmappertest/supplemental_diagnostics.go +++ b/tsc/internal/testutil/contentmappertest/supplemental_diagnostics.go @@ -33,8 +33,8 @@ func (supplementalDiagnosticsHandler) HandleRequest(ctx context.Context, method return nil, err } return contentmapper.TransformResult{ - MappedOutput: contentmapper.MappedOutput{Text: "export {};", Extension: ".ts"}, - Supplemental: []contentmapper.SupplementalOutput{{MappedOutput: contentmapper.MappedOutput{Text: prefix + p.Content, Extension: ".ts", Mappings: json.Value(mappings)}}}, + Text: "export {};", Extension: ".ts", + Supplemental: []contentmapper.SupplementalOutput{{Text: prefix + p.Content, Extension: ".ts", Mappings: json.Value(mappings)}}, }, nil default: return nil, fmt.Errorf("contentmappertest: unexpected method %q", method) diff --git a/tsc/internal/testutil/contentmappertest/supplemental_globals.go b/tsc/internal/testutil/contentmappertest/supplemental_globals.go index 61ea039af034f..d6833a7856fe5 100644 --- a/tsc/internal/testutil/contentmappertest/supplemental_globals.go +++ b/tsc/internal/testutil/contentmappertest/supplemental_globals.go @@ -30,8 +30,8 @@ func (supplementalGlobalsHandler) HandleRequest(ctx context.Context, method stri return nil, fmt.Errorf("contentmappertest: unexpected supplemental global input %q", p.FileName) } return contentmapper.TransformResult{ - MappedOutput: contentmapper.MappedOutput{Text: "export default shared.value;", Extension: ".ts"}, - Supplemental: []contentmapper.SupplementalOutput{{MappedOutput: contentmapper.MappedOutput{Text: supplemental, Extension: ".ts"}}}, + Text: "export default shared.value;", Extension: ".ts", + Supplemental: []contentmapper.SupplementalOutput{{Text: supplemental, Extension: ".ts"}}, }, nil default: return nil, fmt.Errorf("contentmappertest: unexpected method %q", method) diff --git a/tsc/internal/testutil/contentmappertest/supplemental_module.go b/tsc/internal/testutil/contentmappertest/supplemental_module.go index 44a89b11497a7..8fca4fe0d549f 100644 --- a/tsc/internal/testutil/contentmappertest/supplemental_module.go +++ b/tsc/internal/testutil/contentmappertest/supplemental_module.go @@ -20,8 +20,8 @@ func (supplementalModuleHandler) HandleRequest(ctx context.Context, method strin return nil, err } return contentmapper.TransformResult{ - MappedOutput: contentmapper.MappedOutput{Text: "export default 1;", Extension: ".ts"}, - Supplemental: []contentmapper.SupplementalOutput{{MappedOutput: contentmapper.MappedOutput{Text: `export const privateValue: number = "wrong";`, Extension: ".ts"}}}, + Text: "export default 1;", Extension: ".ts", + Supplemental: []contentmapper.SupplementalOutput{{Text: `export const privateValue: number = "wrong";`, Extension: ".ts"}}, }, nil default: return nil, fmt.Errorf("contentmappertest: unexpected method %q", method) diff --git a/tsc/internal/testutil/contentmappertest/synthesizing.go b/tsc/internal/testutil/contentmappertest/synthesizing.go index 7c79dfa34b822..de35db3ddef0e 100644 --- a/tsc/internal/testutil/contentmappertest/synthesizing.go +++ b/tsc/internal/testutil/contentmappertest/synthesizing.go @@ -26,11 +26,11 @@ func (synthesizingHandler) HandleRequest(ctx context.Context, method string, par if err != nil { return nil, err } - return contentmapper.TransformResult{MappedOutput: contentmapper.MappedOutput{ + return contentmapper.TransformResult{ Text: synthesizedOutput, Extension: ".ts", Mappings: json.Value(mappings), - }}, nil + }, nil default: return nil, fmt.Errorf("contentmappertest: unexpected method %q", method) } diff --git a/tsc/internal/testutil/contentmappertest/transforming.go b/tsc/internal/testutil/contentmappertest/transforming.go index 41da490b47e5b..42ba711ea76a5 100644 --- a/tsc/internal/testutil/contentmappertest/transforming.go +++ b/tsc/internal/testutil/contentmappertest/transforming.go @@ -72,8 +72,8 @@ func (h *Handler) HandleRequest(ctx context.Context, method string, params json. return nil, err } return contentmapper.TransformResult{ - MappedOutput: contentmapper.MappedOutput{Text: text, Extension: mappedExtension(p.Content), Mappings: mappings, DiagnosticDirectives: diagnosticDirectives}, - Diagnostics: diagnostics, + Text: text, Extension: mappedExtension(p.Content), Mappings: mappings, DiagnosticDirectives: diagnosticDirectives, + Diagnostics: diagnostics, }, nil default: return nil, fmt.Errorf("contentmappertest: unexpected method %q", method) diff --git a/tsc/internal/transformers/estransforms/taggedtemplate.go b/tsc/internal/transformers/estransforms/taggedtemplate.go index 0beaf57e53d09..0349e7a79d13b 100644 --- a/tsc/internal/transformers/estransforms/taggedtemplate.go +++ b/tsc/internal/transformers/estransforms/taggedtemplate.go @@ -1,6 +1,7 @@ package estransforms import ( + "slices" "strings" "github.com/microsoft/TypeScript/tsc/internal/ast" @@ -45,7 +46,7 @@ func (tx *taggedTemplateTransformer) visitSourceFile(node *ast.SourceFile) *ast. if len(tx.taggedTemplateStringDeclarations) > 0 { visitedSourceFile := visited.AsSourceFile() statements := append( - visitedSourceFile.Statements.Nodes[:len(visitedSourceFile.Statements.Nodes):len(visitedSourceFile.Statements.Nodes)], + slices.Clip(visitedSourceFile.Statements.Nodes), tx.Factory().NewVariableStatement( nil, /*modifiers*/ tx.Factory().NewVariableDeclarationList( diff --git a/tsc/internal/tsoptions/contentmappers_test.go b/tsc/internal/tsoptions/contentmappers_test.go index 6d2bc9875126b..c5785dfb80f1b 100644 --- a/tsc/internal/tsoptions/contentmappers_test.go +++ b/tsc/internal/tsoptions/contentmappers_test.go @@ -19,8 +19,8 @@ type resolveContentMapperHost struct { func TestGetContentMapperForFileNameUsesLongestExtension(t *testing.T) { t.Parallel() - zMapper := &contentmapper.Mapper{Definition: contentmapper.Definition{Package: "z", Extensions: []string{".z"}}} - yzMapper := &contentmapper.Mapper{Definition: contentmapper.Definition{Package: "yz", Extensions: []string{".y.z"}}} + zMapper := &contentmapper.Mapper{Package: "z", Extensions: []string{".z"}} + yzMapper := &contentmapper.Mapper{Package: "yz", Extensions: []string{".y.z"}} commandLine := &ParsedCommandLine{ParsedConfig: &ParsedOptions{ContentMappers: []*contentmapper.Mapper{zMapper, yzMapper}}} assert.Equal(t, commandLine.GetContentMapperForFileName("/src/Component.y.z"), yzMapper) @@ -29,7 +29,7 @@ func TestGetContentMapperForFileNameUsesLongestExtension(t *testing.T) { func TestGetContentMapperForFileNameUsesHostCaseSensitivity(t *testing.T) { t.Parallel() - mapper := &contentmapper.Mapper{Definition: contentmapper.Definition{Extensions: []string{".vue"}}} + mapper := &contentmapper.Mapper{Extensions: []string{".vue"}} insensitive := &ParsedCommandLine{ ParsedConfig: &ParsedOptions{ContentMappers: []*contentmapper.Mapper{mapper}}, comparePathsOptions: tspath.ComparePathsOptions{UseCaseSensitiveFileNames: false}, @@ -45,7 +45,7 @@ func TestGetContentMapperForFileNameUsesHostCaseSensitivity(t *testing.T) { func TestGetOutputFileNamesExcludesMapperOwnedOutputs(t *testing.T) { t.Parallel() - mapper := &contentmapper.Mapper{Definition: contentmapper.Definition{Extensions: []string{".vue"}}} + mapper := &contentmapper.Mapper{Extensions: []string{".vue"}} commandLine := NewParsedCommandLine( &core.CompilerOptions{ OutDir: "/dist", diff --git a/tsc/internal/tsoptions/tsconfigparsing_test.go b/tsc/internal/tsoptions/tsconfigparsing_test.go index 85d15386919dc..69e62efc17724 100644 --- a/tsc/internal/tsoptions/tsconfigparsing_test.go +++ b/tsc/internal/tsoptions/tsconfigparsing_test.go @@ -140,11 +140,9 @@ func TestParseConfigFileTextToJson(t *testing.T) { baselineContent.WriteString("\n") baselineContent.WriteString("Errors::\n") diagnosticwriter.FormatDiagnosticsWithColorAndContext(&baselineContent, diagnosticwriter.FromASTDiagnostics(errors), &diagnosticwriter.FormattingOptions{ - NewLine: "\n", - ComparePathsOptions: tspath.ComparePathsOptions{ - CurrentDirectory: "/", - UseCaseSensitiveFileNames: true, - }, + NewLine: "\n", + CurrentDirectory: "/", + UseCaseSensitiveFileNames: true, }) baselineContent.WriteString("\n") if i != len(rec.input)-1 { @@ -1537,11 +1535,9 @@ func baselineParseConfigWith(t *testing.T, baselineFileName string, includeCompi baselineContent.WriteString("\n") baselineContent.WriteString("Errors::\n") diagnosticwriter.FormatDiagnosticsWithColorAndContext(&baselineContent, diagnosticwriter.FromASTDiagnostics(parsedConfigFileContent.Errors), &diagnosticwriter.FormattingOptions{ - NewLine: "\r\n", - ComparePathsOptions: tspath.ComparePathsOptions{ - CurrentDirectory: basePath, - UseCaseSensitiveFileNames: true, - }, + NewLine: "\r\n", + CurrentDirectory: basePath, + UseCaseSensitiveFileNames: true, }) baselineContent.WriteString("\n") if i != len(input)-1 { From c5c9a0bca53bd26a36b356de2311af2d69fd1a1b Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 20 Aug 2026 02:59:02 -0700 Subject: [PATCH 6/8] Apply slicesbackward modernizer --- .dprint.jsonc | 2 +- .golangci.yml | 4 ---- tsc/internal/astnav/tokens.go | 13 +++++++------ tsc/internal/checker/checker.go | 6 +++--- tsc/internal/core/core.go | 6 ++---- tsc/internal/format/span.go | 4 ++-- tsc/internal/fourslash/fourslash.go | 16 ++++++++-------- tsc/internal/fswatch/watcher.go | 8 ++++---- tsc/internal/ls/documenthighlights.go | 13 +++++++------ tsc/internal/ls/lsutil/children.go | 8 +++++--- tsc/internal/ls/symbols.go | 4 ++-- tsc/internal/printer/utilities.go | 3 +-- tsc/internal/pseudochecker/lookup.go | 4 ++-- tsc/internal/tsoptions/tsconfigparsing.go | 4 ++-- 14 files changed, 46 insertions(+), 49 deletions(-) diff --git a/.dprint.jsonc b/.dprint.jsonc index 15ae55f237c05..0bfc480fe4778 100644 --- a/.dprint.jsonc +++ b/.dprint.jsonc @@ -38,7 +38,7 @@ "trailingCommas": "never" }, "gofumpt": { - "langVersion": "go1.26", + "langVersion": "go1.27", "modulePath": "github.com/microsoft/TypeScript/tsc" }, "excludes": [ diff --git a/.golangci.yml b/.golangci.yml index 1309650b71452..6dad8234aa2e5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -65,10 +65,6 @@ linters: customlint: type: module - modernize: - disable: - - slicesbackward # https://github.com/golang/go/issues/78829 - depguard: rules: main: diff --git a/tsc/internal/astnav/tokens.go b/tsc/internal/astnav/tokens.go index 9b6b3257df890..b921912ad6884 100644 --- a/tsc/internal/astnav/tokens.go +++ b/tsc/internal/astnav/tokens.go @@ -2,6 +2,7 @@ package astnav import ( "fmt" + "slices" "github.com/microsoft/TypeScript/tsc/internal/ast" "github.com/microsoft/TypeScript/tsc/internal/core" @@ -142,9 +143,9 @@ func getTokenAtPosition( if nodeList.End() == position && includePrecedingTokenAtEndPosition != nil { left = nodeList.End() nodeAfterLeft = nil - for i := len(nodeList.Nodes) - 1; i >= 0; i-- { - if nodeList.Nodes[i].Flags&ast.NodeFlagsReparsed == 0 { - prevSubtree = nodeList.Nodes[i] + for _, v := range slices.Backward(nodeList.Nodes) { + if v.Flags&ast.NodeFlagsReparsed == 0 { + prevSubtree = v break } } @@ -416,9 +417,9 @@ func FindPrecedingTokenEx(sourceFile *ast.SourceFile, position int, startNode *a // Find jsdoc preceding the foundChild. var jsDoc *ast.Node nodeJSDoc := n.JSDoc(sourceFile) - for i := len(nodeJSDoc) - 1; i >= 0; i-- { - if nodeJSDoc[i].Pos() >= foundChild.Pos() { - jsDoc = nodeJSDoc[i] + for _, n := range slices.Backward(nodeJSDoc) { + if n.Pos() >= foundChild.Pos() { + jsDoc = n break } } diff --git a/tsc/internal/checker/checker.go b/tsc/internal/checker/checker.go index 9c9cb64c78a31..8cbf7ea93edd5 100644 --- a/tsc/internal/checker/checker.go +++ b/tsc/internal/checker/checker.go @@ -31109,9 +31109,9 @@ func (c *Checker) popInferenceContext() { } func (c *Checker) getInferenceContext(node *ast.Node) *InferenceContext { - for i := len(c.inferenceContextInfos) - 1; i >= 0; i-- { - if isNodeDescendantOf(node, c.inferenceContextInfos[i].node) { - return c.inferenceContextInfos[i].context + for _, v := range slices.Backward(c.inferenceContextInfos) { + if isNodeDescendantOf(node, v.node) { + return v.context } } return nil diff --git a/tsc/internal/core/core.go b/tsc/internal/core/core.go index cb5cd9b6d8327..7436c0cb3186e 100644 --- a/tsc/internal/core/core.go +++ b/tsc/internal/core/core.go @@ -226,8 +226,7 @@ func Find[T any](slice []T, f func(T) bool) T { } func FindLast[T any](slice []T, f func(T) bool) T { - for i := len(slice) - 1; i >= 0; i-- { - value := slice[i] + for _, value := range slices.Backward(slice) { if f(value) { return value } @@ -245,8 +244,7 @@ func FindIndex[T any](slice []T, f func(T) bool) int { } func FindLastIndex[T any](slice []T, f func(T) bool) int { - for i := len(slice) - 1; i >= 0; i-- { - value := slice[i] + for i, value := range slices.Backward(slice) { if f(value) { return i } diff --git a/tsc/internal/format/span.go b/tsc/internal/format/span.go index ef268c873a404..0d8bc0d973142 100644 --- a/tsc/internal/format/span.go +++ b/tsc/internal/format/span.go @@ -659,8 +659,8 @@ func (w *formatSpanWorker) processPair(currentItem TextRangeWithKind, currentSta if len(w.currentRules) > 0 { // Apply rules in reverse order so that higher priority rules (which are first in the array) // win in a conflict with lower priority rules. - for i := len(w.currentRules) - 1; i >= 0; i-- { - rule := w.currentRules[i] + for _, rule := range slices.Backward(w.currentRules) { + lineAction = w.applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine) if dynamicIndentation != nil { switch lineAction { diff --git a/tsc/internal/fourslash/fourslash.go b/tsc/internal/fourslash/fourslash.go index 583fda609fa9e..cef5ed066f75f 100644 --- a/tsc/internal/fourslash/fourslash.go +++ b/tsc/internal/fourslash/fourslash.go @@ -2118,8 +2118,8 @@ func (f *FourslashTest) applyEditsToContent(content string, edits []*lsproto.Tex bStart := f.converters.LineAndCharacterToPosition(script, b.Range.Start) return int(aStart) - int(bStart) }) - for i := len(edits) - 1; i >= 0; i-- { - edit := edits[i] + for _, edit := range slices.Backward(edits) { + start := int(f.converters.LineAndCharacterToPosition(script, edit.Range.Start)) end := int(f.converters.LineAndCharacterToPosition(script, edit.Range.End)) content = content[:start] + edit.NewText + content[end:] @@ -3356,8 +3356,8 @@ func (f *FourslashTest) VerifyBaselineSelectionRanges(t *testing.T) { } trailingWidth := -1 - for j := len(maskedRunes) - 1; j >= 0; j-- { - if isRealCharacter(maskedRunes[j]) { + for j, maskedRune := range slices.Backward(maskedRunes) { + if isRealCharacter(maskedRune) { trailingWidth = j break } @@ -3980,8 +3980,8 @@ func (f *FourslashTest) applyTextEdits(t *testing.T, edits []*lsproto.TextEdit) totalOffset := 0 currentCaretPosition := int(f.converters.LineAndCharacterToPosition(script, f.currentCaretPosition)) // Apply edits in reverse order to avoid affecting the positions of earlier edits. - for i := len(edits) - 1; i >= 0; i-- { - edit := edits[i] + for _, edit := range slices.Backward(edits) { + start := int(f.converters.LineAndCharacterToPosition(script, edit.Range.Start)) end := int(f.converters.LineAndCharacterToPosition(script, edit.Range.End)) f.editScriptAndUpdateMarkers(t, f.activeFilename, start, end, edit.NewText) @@ -4069,8 +4069,8 @@ func (f *FourslashTest) editScriptAndUpdateMarkersWorker(t *testing.T, fileName }) // Apply changes in reverse order to preserve positions of earlier changes - for i := len(sortedChanges) - 1; i >= 0; i-- { - change := sortedChanges[i] + for _, change := range slices.Backward(sortedChanges) { + editStart := change.Pos() editEnd := change.End() script := f.editScript(t, fileName, change) diff --git a/tsc/internal/fswatch/watcher.go b/tsc/internal/fswatch/watcher.go index fa8a7489841d7..44ea4d141ed40 100644 --- a/tsc/internal/fswatch/watcher.go +++ b/tsc/internal/fswatch/watcher.go @@ -270,8 +270,8 @@ func (w *fallbackWatcher) WatchDirectories(requests []WatchDirectoryRequest) ([] watches = make([]Watch, 0, len(requests)) rollback := func() { - for i := len(watches) - 1; i >= 0; i-- { - _ = watches[i].Close() + for _, watch := range slices.Backward(watches) { + _ = watch.Close() } } for _, request := range requests { @@ -491,8 +491,8 @@ func (w *watcher) WatchDirectories(requests []WatchDirectoryRequest) ([]Watch, e uniqueDirWatches := make([]*dirWatch, 0, len(requests)) seenDirWatches := make(map[*dirWatch]struct{}, len(requests)) rollback := func() { - for i := len(prepared) - 1; i >= 0; i-- { - p := prepared[i] + for _, p := range slices.Backward(prepared) { + p.dw.unwatch(p.id) p.dw.unref(w) } diff --git a/tsc/internal/ls/documenthighlights.go b/tsc/internal/ls/documenthighlights.go index e3e8be49d1402..b2f0bc30d16a6 100644 --- a/tsc/internal/ls/documenthighlights.go +++ b/tsc/internal/ls/documenthighlights.go @@ -2,6 +2,7 @@ package ls import ( "context" + "slices" "github.com/microsoft/TypeScript/tsc/internal/ast" "github.com/microsoft/TypeScript/tsc/internal/astnav" @@ -364,9 +365,9 @@ func getIfElseKeywords(ifStatement *ast.IfStatement, sourceFile *ast.SourceFile) keywords = append(keywords, children[0]) } // Generally the 'else' keyword is second-to-last, so traverse backwards. - for i := len(children) - 1; i >= 0; i-- { - if children[i].Kind == ast.KindElseKeyword { - keywords = append(keywords, children[i]) + for _, c := range slices.Backward(children) { + if c.Kind == ast.KindElseKeyword { + keywords = append(keywords, c) break } } @@ -639,9 +640,9 @@ func getLoopBreakContinueOccurrences(node *ast.Node, sourceFile *ast.SourceFile) keywords = append(keywords, token) if node.Kind == ast.KindDoStatement { loopTokens := getChildrenFromNonJSDocNode(node, sourceFile) - for i := len(loopTokens) - 1; i >= 0; i-- { - if loopTokens[i].Kind == ast.KindWhileKeyword { - keywords = append(keywords, loopTokens[i]) + for _, loopToken := range slices.Backward(loopTokens) { + if loopToken.Kind == ast.KindWhileKeyword { + keywords = append(keywords, loopToken) break } } diff --git a/tsc/internal/ls/lsutil/children.go b/tsc/internal/ls/lsutil/children.go index 0a5ecf2a991e0..93ccb5a0ba3e2 100644 --- a/tsc/internal/ls/lsutil/children.go +++ b/tsc/internal/ls/lsutil/children.go @@ -1,6 +1,8 @@ package lsutil import ( + "slices" + "github.com/microsoft/TypeScript/tsc/internal/ast" "github.com/microsoft/TypeScript/tsc/internal/astnav" "github.com/microsoft/TypeScript/tsc/internal/core" @@ -68,9 +70,9 @@ func GetLastVisitedChild(node *ast.Node, sourceFile *ast.SourceFile) *ast.Node { } visitNodeList := func(nodeList *ast.NodeList, _ *ast.NodeVisitor) *ast.NodeList { if nodeList != nil && len(nodeList.Nodes) > 0 { - for i := len(nodeList.Nodes) - 1; i >= 0; i-- { - if nodeList.Nodes[i].Flags&ast.NodeFlagsReparsed == 0 { - lastChild = nodeList.Nodes[i] + for _, v := range slices.Backward(nodeList.Nodes) { + if v.Flags&ast.NodeFlagsReparsed == 0 { + lastChild = v break } } diff --git a/tsc/internal/ls/symbols.go b/tsc/internal/ls/symbols.go index c9a6d4e27fa42..fd261814ccad6 100644 --- a/tsc/internal/ls/symbols.go +++ b/tsc/internal/ls/symbols.go @@ -381,8 +381,8 @@ func mergeExpandos(symbols []*lsproto.DocumentSymbol) []*lsproto.DocumentSymbol // Merge expandos. if symbol.Kind == lsproto.SymbolKindProperty { symbolsWithSameName := nameToExpandoTargetIndex.Get(symbol.Name) - for j := len(symbolsWithSameName) - 1; j >= 0; j-- { - targetIndex := symbolsWithSameName[j] + for _, targetIndex := range slices.Backward(symbolsWithSameName) { + targetSymbol := symbols[targetIndex] mergeChildren(targetSymbol, symbol) // Mark this symbol as merged. diff --git a/tsc/internal/printer/utilities.go b/tsc/internal/printer/utilities.go index 0ae6a6a833854..857928ebf9f3a 100644 --- a/tsc/internal/printer/utilities.go +++ b/tsc/internal/printer/utilities.go @@ -603,8 +603,7 @@ func tryGetEnd(node interface{ End() int }) (int, bool) { } func greatestEnd(end int, nodes ...interface{ End() int }) int { - for i := len(nodes) - 1; i >= 0; i-- { - node := nodes[i] + for _, node := range slices.Backward(nodes) { if nodeEnd, ok := tryGetEnd(node); ok && end < nodeEnd { end = nodeEnd } diff --git a/tsc/internal/pseudochecker/lookup.go b/tsc/internal/pseudochecker/lookup.go index 38d4c30ec0a08..c2693a7ab1552 100644 --- a/tsc/internal/pseudochecker/lookup.go +++ b/tsc/internal/pseudochecker/lookup.go @@ -608,8 +608,8 @@ func isOptionalInitializedOrRestParameter(node *ast.ParameterDeclarationNode) bo // determine "has required parameter after index i" with `i+1 < lastRequired` // (equivalently, `i < lastRequired-1`) in O(1). func lastRequiredParamIndex(params []*ast.Node) int { - for i := len(params) - 1; i >= 0; i-- { - if !isOptionalInitializedOrRestParameter(params[i]) { + for i, param := range slices.Backward(params) { + if !isOptionalInitializedOrRestParameter(param) { return i + 1 } } diff --git a/tsc/internal/tsoptions/tsconfigparsing.go b/tsc/internal/tsoptions/tsconfigparsing.go index e491d40221679..8f50493b2747c 100644 --- a/tsc/internal/tsoptions/tsconfigparsing.go +++ b/tsc/internal/tsoptions/tsconfigparsing.go @@ -1914,8 +1914,8 @@ func removeWildcardFilesWithLowerPriorityExtension(file string, wildcardFiles *c if extensionGroup == nil { return } - for i := len(extensionGroup) - 1; i >= 0; i-- { - ext := extensionGroup[i] + for _, ext := range slices.Backward(extensionGroup) { + if tspath.FileExtensionIs(file, ext) { return } From c7b7f0fa5b37a69b7a340431a7c7a455f94b8661 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 21 Aug 2026 12:23:44 -0700 Subject: [PATCH 7/8] Complete Go 1.27 development setup --- .devcontainer/devcontainer.json | 3 +++ .golangci.yml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0641f41ef0ca4..39b3987f6b761 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,9 @@ { "name": "TypeScript Compiler Development", "image": "mcr.microsoft.com/devcontainers/go:dev-1.26-bookworm", + "containerEnv": { + "GOTOOLCHAIN": "go1.27.0" + }, "features": { "ghcr.io/devcontainers/features/node:2": { "version": "24", diff --git a/.golangci.yml b/.golangci.yml index 6dad8234aa2e5..b2a47fb458a92 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -73,6 +73,8 @@ linters: desc: 'Use "github.com/microsoft/TypeScript/tsc/internal/json" instead.' - pkg: 'encoding/json/v2' desc: 'Use "github.com/microsoft/TypeScript/tsc/internal/json" instead.' + - pkg: 'encoding/json/jsontext' + desc: 'Use "github.com/microsoft/TypeScript/tsc/internal/json" instead.' forbidigo: analyze-types: true From 1287f18e5630432bbe992f48fa072d576d8f5f7a Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 21 Aug 2026 12:25:26 -0700 Subject: [PATCH 8/8] Use synctest.Sleep --- tsc/internal/lsp/progress_test.go | 21 +++++++-------------- tsc/internal/project/checkerpool_test.go | 21 +++++++-------------- tsc/internal/project/watchtimeout_test.go | 6 ++---- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/tsc/internal/lsp/progress_test.go b/tsc/internal/lsp/progress_test.go index f442087af4997..1f43119dae5cf 100644 --- a/tsc/internal/lsp/progress_test.go +++ b/tsc/internal/lsp/progress_test.go @@ -85,8 +85,7 @@ func TestProgress(t *testing.T) { synctest.Wait() // Advance time past the delay to ensure no progress is sent. - time.Sleep(600 * time.Millisecond) - synctest.Wait() + synctest.Sleep(600 * time.Millisecond) calls := reporter.getCalls() if len(calls) != 0 { @@ -109,8 +108,7 @@ func TestProgress(t *testing.T) { synctest.Wait() // Let the delay fire. - time.Sleep(500 * time.Millisecond) - synctest.Wait() + synctest.Sleep(500 * time.Millisecond) calls := reporter.getCalls() if len(calls) != 2 { @@ -154,8 +152,7 @@ func TestProgress(t *testing.T) { synctest.Wait() // Let the delay fire. - time.Sleep(100 * time.Millisecond) - synctest.Wait() + synctest.Sleep(100 * time.Millisecond) calls := reporter.getCalls() // Should have: create, begin (with first message). @@ -212,8 +209,7 @@ func TestProgress(t *testing.T) { p.start(diagnostics.Project_0, "proj") synctest.Wait() - time.Sleep(100 * time.Millisecond) - synctest.Wait() + synctest.Sleep(100 * time.Millisecond) // Finish once (ref count = 1) — should NOT end. p.finish(diagnostics.Project_0, "proj") @@ -251,8 +247,7 @@ func TestProgress(t *testing.T) { // First cycle. p.start(diagnostics.Project_0, "proj") synctest.Wait() - time.Sleep(100 * time.Millisecond) - synctest.Wait() + synctest.Sleep(100 * time.Millisecond) calls := reporter.getCalls() firstToken := calls[0].token @@ -263,8 +258,7 @@ func TestProgress(t *testing.T) { // Second cycle — should get a new token. p.start(diagnostics.Project_0, "proj2") synctest.Wait() - time.Sleep(100 * time.Millisecond) - synctest.Wait() + synctest.Sleep(100 * time.Millisecond) calls = reporter.getCalls() var secondToken string @@ -301,8 +295,7 @@ func TestProgress(t *testing.T) { synctest.Wait() // Let delay fire. - time.Sleep(200 * time.Millisecond) - synctest.Wait() + synctest.Sleep(200 * time.Millisecond) calls := reporter.getCalls() if len(calls) < 2 { diff --git a/tsc/internal/project/checkerpool_test.go b/tsc/internal/project/checkerpool_test.go index 76fdcf12a7e10..fbd9f8dcef119 100644 --- a/tsc/internal/project/checkerpool_test.go +++ b/tsc/internal/project/checkerpool_test.go @@ -152,8 +152,7 @@ func TestCheckerPoolIdleCleanup(t *testing.T) { pool.mu.Unlock() // Advance past idle timeout. - time.Sleep(5 * time.Second) - synctest.Wait() + synctest.Sleep(5 * time.Second) // After cleanup, both checkers should be disposed. pool.mu.Lock() @@ -190,8 +189,7 @@ func TestCheckerPoolFileAssociationCleanup(t *testing.T) { assert.Assert(t, hasAssoc, "file should have a checker association") // Advance past idle timeout. - time.Sleep(5 * time.Second) - synctest.Wait() + synctest.Sleep(5 * time.Second) // File association should be cleared. pool.mu.Lock() @@ -428,8 +426,7 @@ func TestCheckerPoolDiagnosticsRecreatedAfterIdleDisposal(t *testing.T) { synctest.Wait() // Advance past idle timeout — diagnostics checker should be disposed. - time.Sleep(5 * time.Second) - synctest.Wait() + synctest.Sleep(5 * time.Second) pool.mu.Lock() assert.Assert(t, pool.checkers[0] == nil, "diagnostics checker should be disposed") @@ -634,8 +631,7 @@ func TestCheckerPoolDiscardKeepsIdleCheckers(t *testing.T) { pool.mu.Unlock() // Even after a long wait, checkers should not be disposed (no timer running). - time.Sleep(60 * time.Second) - synctest.Wait() + synctest.Sleep(60 * time.Second) pool.mu.Lock() assert.Assert(t, pool.checkers[0] == c1, "diagnostics checker should persist indefinitely on discarded pool") @@ -687,8 +683,7 @@ func TestCheckerPoolDiscardHeldCheckerSurvivesRelease(t *testing.T) { pool.mu.Unlock() // Even after a long wait, checker persists (no cleanup timer running). - time.Sleep(60 * time.Second) - synctest.Wait() + synctest.Sleep(60 * time.Second) pool.mu.Lock() assert.Assert(t, pool.checkers[heldIndex] == c, "checker should persist indefinitely on discarded pool") @@ -850,8 +845,7 @@ func TestCheckerPoolAPICheckerStableIdentity(t *testing.T) { release2() // Should survive idle timeout. - time.Sleep(60 * time.Second) - synctest.Wait() + synctest.Sleep(60 * time.Second) c3, release3 := pool.GetChecker(ctx, nil) assert.Assert(t, c3 == c1, "API checker should survive idle timeout") @@ -1093,8 +1087,7 @@ func TestCheckerPoolStaggeredIdleCleanup(t *testing.T) { // Advance past t=16 (when the timer fires). Both should be disposed // because A has been idle 16s and B has been idle 10s. - time.Sleep(11 * time.Second) - synctest.Wait() + synctest.Sleep(11 * time.Second) pool.mu.Lock() assert.Assert(t, pool.checkers[idxA] == nil, "checker A should be disposed after timer fires") diff --git a/tsc/internal/project/watchtimeout_test.go b/tsc/internal/project/watchtimeout_test.go index 4e77f430c94ea..129749dd0e1bb 100644 --- a/tsc/internal/project/watchtimeout_test.go +++ b/tsc/internal/project/watchtimeout_test.go @@ -69,8 +69,7 @@ func TestUpdateWatchTimeoutAndRollback(t *testing.T) { // Let the background goroutine block on WatchFiles, then advance // fake time past the 1s watchRequestTimeout. synctest.Wait() - time.Sleep(2 * time.Second) - synctest.Wait() + synctest.Sleep(2 * time.Second) mu.Lock() firstAttemptIDs := append([]project.WatcherID(nil), attemptedIDs...) @@ -108,8 +107,7 @@ func TestUpdateWatchTimeoutAndRollback(t *testing.T) { // Let the background task run updateWatches. synctest.Wait() - time.Sleep(2 * time.Second) - synctest.Wait() + synctest.Sleep(2 * time.Second) // Verify: WatchFiles was called again with the same watcher IDs, // and this time the calls succeeded.