diff --git a/.golangci.yml b/.golangci.yml index 4be2885898..afb62f07e9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -68,7 +68,7 @@ linters: main: deny: - pkg: 'encoding/json$' - desc: 'Use "github.com/microsoft/typescript-go/internal/json" instead.' + desc: 'Use "github.com/go-json-experiment/json" instead.' exclusions: rules: diff --git a/internal/api/api.go b/internal/api/api.go index 3f1ec266e0..b1ee7c658f 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -6,12 +6,12 @@ import ( "fmt" "sync" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/api/encoder" "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/astnav" "github.com/microsoft/typescript-go/internal/checker" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/project" "github.com/microsoft/typescript-go/internal/tsoptions" diff --git a/internal/api/proto.go b/internal/api/proto.go index 92bd38f13d..58efc5dcd9 100644 --- a/internal/api/proto.go +++ b/internal/api/proto.go @@ -6,10 +6,11 @@ import ( "strconv" "strings" + "github.com/go-json-experiment/json" + "github.com/go-json-experiment/json/jsontext" "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/checker" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/project" ) @@ -200,7 +201,7 @@ type GetSourceFileParams struct { FileName string `json:"fileName"` } -func unmarshalPayload(method string, payload json.Value) (any, error) { +func unmarshalPayload(method string, payload jsontext.Value) (any, error) { unmarshaler, ok := unmarshalers[Method(method)] if !ok { return nil, fmt.Errorf("unknown API method %q", method) diff --git a/internal/api/server.go b/internal/api/server.go index cc5736fa33..5f88ad20d3 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -9,9 +9,9 @@ import ( "strconv" "sync" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/bundled" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/project" "github.com/microsoft/typescript-go/internal/vfs" "github.com/microsoft/typescript-go/internal/vfs/osvfs" diff --git a/internal/collections/ordered_map.go b/internal/collections/ordered_map.go index 4cfd7f773c..9c321b0941 100644 --- a/internal/collections/ordered_map.go +++ b/internal/collections/ordered_map.go @@ -9,8 +9,8 @@ import ( "slices" "strconv" + "github.com/go-json-experiment/json" "github.com/go-json-experiment/json/jsontext" - "github.com/microsoft/typescript-go/internal/json" ) // OrderedMap is an insertion ordered map. diff --git a/internal/collections/ordered_map_test.go b/internal/collections/ordered_map_test.go index 16945c791f..0138d992d2 100644 --- a/internal/collections/ordered_map_test.go +++ b/internal/collections/ordered_map_test.go @@ -5,8 +5,8 @@ import ( "slices" "testing" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/collections" - "github.com/microsoft/typescript-go/internal/json" "gotest.tools/v3/assert" ) diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 784faf7a73..badd3c832e 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -8,13 +8,13 @@ import ( "strings" "sync" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/binder" "github.com/microsoft/typescript-go/internal/checker" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/modulespecifiers" "github.com/microsoft/typescript-go/internal/outputpaths" diff --git a/internal/core/core.go b/internal/core/core.go index 48856c2ff8..a14fb98290 100644 --- a/internal/core/core.go +++ b/internal/core/core.go @@ -9,7 +9,7 @@ import ( "unicode" "unicode/utf8" - "github.com/microsoft/typescript-go/internal/json" + "github.com/microsoft/typescript-go/internal/jsonutil" "github.com/microsoft/typescript-go/internal/stringutil" "github.com/microsoft/typescript-go/internal/tspath" ) @@ -427,7 +427,7 @@ func FirstResult[T1 any](t1 T1, _ ...any) T1 { } func StringifyJson(input any, prefix string, indent string) (string, error) { - output, err := json.MarshalIndent(input, prefix, indent) + output, err := jsonutil.MarshalIndent(input, prefix, indent) return string(output), err } diff --git a/internal/diagnostics/generate.go b/internal/diagnostics/generate.go index 97f71fbb5d..991d84dc1d 100644 --- a/internal/diagnostics/generate.go +++ b/internal/diagnostics/generate.go @@ -20,7 +20,7 @@ import ( "strings" "unicode" - "github.com/microsoft/typescript-go/internal/json" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/repo" ) diff --git a/internal/execute/tsc.go b/internal/execute/tsc.go index bbb5511b67..af97431c32 100644 --- a/internal/execute/tsc.go +++ b/internal/execute/tsc.go @@ -14,7 +14,7 @@ import ( "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/format" "github.com/microsoft/typescript-go/internal/incremental" - "github.com/microsoft/typescript-go/internal/json" + "github.com/microsoft/typescript-go/internal/jsonutil" "github.com/microsoft/typescript-go/internal/parser" "github.com/microsoft/typescript-go/internal/pprof" "github.com/microsoft/typescript-go/internal/tsoptions" @@ -413,7 +413,7 @@ func emitFilesAndReportErrors( func showConfig(sys System, config *core.CompilerOptions) { // !!! - _ = json.MarshalIndentWrite(sys.Writer(), config, "", " ") + _ = jsonutil.MarshalIndentWrite(sys.Writer(), config, "", " ") } func listFiles(sys System, program compiler.ProgramLike) { diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index 30a49c5491..c2d15659fd 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -10,12 +10,12 @@ import ( "unicode" "unicode/utf8" + "github.com/go-json-experiment/json" "github.com/google/go-cmp/cmp" "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/bundled" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/ls" "github.com/microsoft/typescript-go/internal/lsp" "github.com/microsoft/typescript-go/internal/lsp/lsproto" diff --git a/internal/fourslash/test_parser.go b/internal/fourslash/test_parser.go index 4b5851512e..697f54da53 100644 --- a/internal/fourslash/test_parser.go +++ b/internal/fourslash/test_parser.go @@ -6,8 +6,8 @@ import ( "testing" "unicode/utf8" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/ls" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/stringutil" diff --git a/internal/incremental/buildInfo.go b/internal/incremental/buildInfo.go index 4317069b0b..9afba79405 100644 --- a/internal/incremental/buildInfo.go +++ b/internal/incremental/buildInfo.go @@ -3,10 +3,11 @@ package incremental import ( "fmt" + "github.com/go-json-experiment/json" + "github.com/go-json-experiment/json/jsontext" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" ) @@ -213,7 +214,7 @@ func (b *BuildInfoDiagnosticsOfFile) MarshalJSON() ([]byte, error) { } func (b *BuildInfoDiagnosticsOfFile) UnmarshalJSON(data []byte) error { - var fileIdAndDiagnostics []json.Value + var fileIdAndDiagnostics []jsontext.Value if err := json.Unmarshal(data, &fileIdAndDiagnostics); err != nil { return fmt.Errorf("invalid BuildInfoDiagnosticsOfFile: %s", data) } diff --git a/internal/incremental/incremental.go b/internal/incremental/incremental.go index 370ee7fe17..0228b34785 100644 --- a/internal/incremental/incremental.go +++ b/internal/incremental/incremental.go @@ -1,8 +1,8 @@ package incremental import ( + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/compiler" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/outputpaths" "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" diff --git a/internal/incremental/program.go b/internal/incremental/program.go index 5945017c5f..6352e782a6 100644 --- a/internal/incremental/program.go +++ b/internal/incremental/program.go @@ -5,11 +5,11 @@ import ( "fmt" "slices" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/outputpaths" "github.com/microsoft/typescript-go/internal/tspath" ) diff --git a/internal/jsnum/string.go b/internal/jsnum/string.go index 79139154fd..371a391599 100644 --- a/internal/jsnum/string.go +++ b/internal/jsnum/string.go @@ -9,7 +9,7 @@ import ( "unicode" "unicode/utf8" - "github.com/microsoft/typescript-go/internal/json" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/stringutil" ) diff --git a/internal/jsnum/string_test.go b/internal/jsnum/string_test.go index 107940a529..29e26aa7c1 100644 --- a/internal/jsnum/string_test.go +++ b/internal/jsnum/string_test.go @@ -9,7 +9,7 @@ import ( "slices" "testing" - "github.com/microsoft/typescript-go/internal/json" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/testutil/jstest" "gotest.tools/v3/assert" ) diff --git a/internal/json/json.go b/internal/json/json.go deleted file mode 100644 index da89d3fce9..0000000000 --- a/internal/json/json.go +++ /dev/null @@ -1,52 +0,0 @@ -package json - -import ( - "io" - - jsonv2 "github.com/go-json-experiment/json" - "github.com/go-json-experiment/json/jsontext" -) - -func Marshal(in any, opts ...jsonv2.Options) (out []byte, err error) { - return jsonv2.Marshal(in, opts...) -} - -func MarshalEncode(out *jsontext.Encoder, in any, opts ...jsonv2.Options) (err error) { - return jsonv2.MarshalEncode(out, in, opts...) -} - -func MarshalWrite(out io.Writer, in any, opts ...jsonv2.Options) (err error) { - return jsonv2.MarshalWrite(out, in, opts...) -} - -func MarshalIndent(in any, prefix, indent string) (out []byte, err error) { - if prefix == "" && indent == "" { - return Marshal(in) - } - return Marshal(in, jsontext.WithIndentPrefix(prefix), jsontext.WithIndent(indent)) -} - -func MarshalIndentWrite(out io.Writer, in any, prefix, indent string) (err error) { - if prefix == "" && indent == "" { - return MarshalWrite(out, in) - } - return MarshalWrite(out, in, jsontext.WithIndentPrefix(prefix), jsontext.WithIndent(indent)) -} - -func Unmarshal(in []byte, out any, opts ...jsonv2.Options) (err error) { - return jsonv2.Unmarshal(in, out, opts...) -} - -func UnmarshalDecode(in *jsontext.Decoder, out any, opts ...jsonv2.Options) (err error) { - return jsonv2.UnmarshalDecode(in, out, opts...) -} - -func UnmarshalRead(in io.Reader, out any, opts ...jsonv2.Options) (err error) { - return jsonv2.UnmarshalRead(in, out, opts...) -} - -type ( - Value = jsontext.Value - UnmarshalerFrom = jsonv2.UnmarshalerFrom - MarshalerTo = jsonv2.MarshalerTo -) diff --git a/internal/jsonutil/jsonutil.go b/internal/jsonutil/jsonutil.go new file mode 100644 index 0000000000..82ae50fc91 --- /dev/null +++ b/internal/jsonutil/jsonutil.go @@ -0,0 +1,24 @@ +package jsonutil + +import ( + "io" + + "github.com/go-json-experiment/json" + "github.com/go-json-experiment/json/jsontext" +) + +func MarshalIndent(in any, prefix, indent string) (out []byte, err error) { + if prefix == "" && indent == "" { + // WithIndentPrefix and WithIndent imply multiline output, so skip them. + return json.Marshal(in) + } + return json.Marshal(in, jsontext.WithIndentPrefix(prefix), jsontext.WithIndent(indent)) +} + +func MarshalIndentWrite(out io.Writer, in any, prefix, indent string) (err error) { + if prefix == "" && indent == "" { + // WithIndentPrefix and WithIndent imply multiline output, so skip them. + return json.MarshalWrite(out, in) + } + return json.MarshalWrite(out, in, jsontext.WithIndentPrefix(prefix), jsontext.WithIndent(indent)) +} diff --git a/internal/ls/completions.go b/internal/ls/completions.go index a12463537d..8a40ca0793 100644 --- a/internal/ls/completions.go +++ b/internal/ls/completions.go @@ -11,6 +11,7 @@ import ( "unicode" "unicode/utf8" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/astnav" "github.com/microsoft/typescript-go/internal/checker" @@ -18,7 +19,6 @@ import ( "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/jsnum" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/lsutil" "github.com/microsoft/typescript-go/internal/scanner" diff --git a/internal/lsp/lsproto/jsonrpc.go b/internal/lsp/lsproto/jsonrpc.go index 902e303757..727b09e14f 100644 --- a/internal/lsp/lsproto/jsonrpc.go +++ b/internal/lsp/lsproto/jsonrpc.go @@ -5,7 +5,8 @@ import ( "fmt" "strconv" - "github.com/microsoft/typescript-go/internal/json" + "github.com/go-json-experiment/json" + "github.com/go-json-experiment/json/jsontext" ) type JSONRPCVersion struct{} @@ -103,7 +104,7 @@ func (m *Message) UnmarshalJSON(data []byte) error { JSONRPC JSONRPCVersion `json:"jsonrpc"` Method Method `json:"method"` ID *ID `json:"id,omitzero"` - Params json.Value `json:"params"` + Params jsontext.Value `json:"params"` Result any `json:"result,omitzero"` Error *ResponseError `json:"error,omitzero"` } @@ -185,7 +186,7 @@ func (r *RequestMessage) UnmarshalJSON(data []byte) error { JSONRPC JSONRPCVersion `json:"jsonrpc"` ID *ID `json:"id"` Method Method `json:"method"` - Params json.Value `json:"params"` + Params jsontext.Value `json:"params"` } if err := json.Unmarshal(data, &raw); err != nil { return fmt.Errorf("%w: %w", ErrInvalidRequest, err) diff --git a/internal/lsp/lsproto/lsp.go b/internal/lsp/lsproto/lsp.go index dd5300702e..6dada4b921 100644 --- a/internal/lsp/lsproto/lsp.go +++ b/internal/lsp/lsproto/lsp.go @@ -3,8 +3,8 @@ package lsproto import ( "fmt" + "github.com/go-json-experiment/json" "github.com/go-json-experiment/json/jsontext" - "github.com/microsoft/typescript-go/internal/json" ) type DocumentUri string // !!! diff --git a/internal/lsp/lsproto/lsp_test.go b/internal/lsp/lsproto/lsp_test.go index e93cfd6b4c..533cac23ec 100644 --- a/internal/lsp/lsproto/lsp_test.go +++ b/internal/lsp/lsproto/lsp_test.go @@ -3,7 +3,7 @@ package lsproto import ( "testing" - "github.com/microsoft/typescript-go/internal/json" + "github.com/go-json-experiment/json" "gotest.tools/v3/assert" ) diff --git a/internal/lsp/server.go b/internal/lsp/server.go index 358d7144e2..778dc0a41c 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -13,9 +13,9 @@ import ( "sync/atomic" "syscall" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/ls" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/project" diff --git a/internal/module/resolver_test.go b/internal/module/resolver_test.go index d2267110c2..1c5456d635 100644 --- a/internal/module/resolver_test.go +++ b/internal/module/resolver_test.go @@ -9,9 +9,10 @@ import ( "sync" "testing" + "github.com/go-json-experiment/json" "github.com/go-json-experiment/json/jsontext" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/json" + "github.com/microsoft/typescript-go/internal/jsonutil" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/repo" "github.com/microsoft/typescript-go/internal/testutil/baseline" @@ -326,7 +327,7 @@ func runTraceBaseline(t *testing.T, test traceTestCase) { if test.trace { t.Run("trace", func(t *testing.T) { - output, err := json.MarshalIndent(resolver, "", " ") + output, err := jsonutil.MarshalIndent(resolver, "", " ") if err != nil { t.Fatal(err) } diff --git a/internal/packagejson/expected.go b/internal/packagejson/expected.go index 1ec1f54c89..eeaf43291f 100644 --- a/internal/packagejson/expected.go +++ b/internal/packagejson/expected.go @@ -3,7 +3,7 @@ package packagejson import ( "reflect" - "github.com/microsoft/typescript-go/internal/json" + "github.com/go-json-experiment/json" ) type Expected[T any] struct { diff --git a/internal/packagejson/expected_test.go b/internal/packagejson/expected_test.go index a5583d38ff..fbe1938327 100644 --- a/internal/packagejson/expected_test.go +++ b/internal/packagejson/expected_test.go @@ -3,7 +3,7 @@ package packagejson_test import ( "testing" - "github.com/microsoft/typescript-go/internal/json" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/packagejson" "gotest.tools/v3/assert" ) diff --git a/internal/packagejson/exportsorimports.go b/internal/packagejson/exportsorimports.go index df5588e6d0..2d3e79360e 100644 --- a/internal/packagejson/exportsorimports.go +++ b/internal/packagejson/exportsorimports.go @@ -1,9 +1,9 @@ package packagejson import ( + "github.com/go-json-experiment/json" "github.com/go-json-experiment/json/jsontext" "github.com/microsoft/typescript-go/internal/collections" - "github.com/microsoft/typescript-go/internal/json" ) type objectKind int8 diff --git a/internal/packagejson/exportsorimports_test.go b/internal/packagejson/exportsorimports_test.go index 7fec71479b..92589b2e5f 100644 --- a/internal/packagejson/exportsorimports_test.go +++ b/internal/packagejson/exportsorimports_test.go @@ -3,7 +3,7 @@ package packagejson_test import ( "testing" - "github.com/microsoft/typescript-go/internal/json" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/packagejson" "gotest.tools/v3/assert" ) diff --git a/internal/packagejson/jsonvalue.go b/internal/packagejson/jsonvalue.go index d31557dc2d..5c38a59310 100644 --- a/internal/packagejson/jsonvalue.go +++ b/internal/packagejson/jsonvalue.go @@ -3,9 +3,9 @@ package packagejson import ( "fmt" + "github.com/go-json-experiment/json" "github.com/go-json-experiment/json/jsontext" "github.com/microsoft/typescript-go/internal/collections" - "github.com/microsoft/typescript-go/internal/json" ) type JSONValueType int8 diff --git a/internal/packagejson/jsonvalue_test.go b/internal/packagejson/jsonvalue_test.go index 2ef43a97d7..7ce53da786 100644 --- a/internal/packagejson/jsonvalue_test.go +++ b/internal/packagejson/jsonvalue_test.go @@ -3,7 +3,7 @@ package packagejson_test import ( "testing" - "github.com/microsoft/typescript-go/internal/json" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/packagejson" "gotest.tools/v3/assert" ) diff --git a/internal/packagejson/packagejson.go b/internal/packagejson/packagejson.go index 3ca99c4303..5db60cebab 100644 --- a/internal/packagejson/packagejson.go +++ b/internal/packagejson/packagejson.go @@ -1,8 +1,8 @@ package packagejson import ( + json "github.com/go-json-experiment/json" "github.com/go-json-experiment/json/jsontext" - json "github.com/microsoft/typescript-go/internal/json" ) type HeaderFields struct { diff --git a/internal/packagejson/packagejson_test.go b/internal/packagejson/packagejson_test.go index 2e5b1f44ba..a2ab08ef5a 100644 --- a/internal/packagejson/packagejson_test.go +++ b/internal/packagejson/packagejson_test.go @@ -4,10 +4,10 @@ import ( "path/filepath" "testing" + "github.com/go-json-experiment/json" "github.com/google/go-cmp/cmp/cmpopts" "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/packagejson" "github.com/microsoft/typescript-go/internal/parser" "github.com/microsoft/typescript-go/internal/repo" diff --git a/internal/project/ata.go b/internal/project/ata.go index 859162f548..c457a62b80 100644 --- a/internal/project/ata.go +++ b/internal/project/ata.go @@ -6,9 +6,9 @@ import ( "sync" "sync/atomic" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/semver" "github.com/microsoft/typescript-go/internal/tspath" diff --git a/internal/project/discovertypings.go b/internal/project/discovertypings.go index 5456d1d3fe..f36400f13d 100644 --- a/internal/project/discovertypings.go +++ b/internal/project/discovertypings.go @@ -6,9 +6,9 @@ import ( "slices" "unicode/utf8" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/packagejson" "github.com/microsoft/typescript-go/internal/semver" "github.com/microsoft/typescript-go/internal/tspath" diff --git a/internal/sourcemap/generator.go b/internal/sourcemap/generator.go index c73ca42090..ea4edab607 100644 --- a/internal/sourcemap/generator.go +++ b/internal/sourcemap/generator.go @@ -5,7 +5,7 @@ import ( "slices" "strings" - "github.com/microsoft/typescript-go/internal/json" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/tspath" ) diff --git a/internal/testutil/harnessutil/sourcemap_recorder.go b/internal/testutil/harnessutil/sourcemap_recorder.go index 714831b5ed..48cdf024c6 100644 --- a/internal/testutil/harnessutil/sourcemap_recorder.go +++ b/internal/testutil/harnessutil/sourcemap_recorder.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/sourcemap" "github.com/microsoft/typescript-go/internal/stringutil" ) diff --git a/internal/testutil/incrementaltestutil/fs.go b/internal/testutil/incrementaltestutil/fs.go index 4b6de59067..cd3fa6b9a1 100644 --- a/internal/testutil/incrementaltestutil/fs.go +++ b/internal/testutil/incrementaltestutil/fs.go @@ -3,9 +3,9 @@ package incrementaltestutil import ( "fmt" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/incremental" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/tspath" "github.com/microsoft/typescript-go/internal/vfs" ) diff --git a/internal/testutil/incrementaltestutil/readablebuildinfo.go b/internal/testutil/incrementaltestutil/readablebuildinfo.go index 62bbeca38b..dbfa965087 100644 --- a/internal/testutil/incrementaltestutil/readablebuildinfo.go +++ b/internal/testutil/incrementaltestutil/readablebuildinfo.go @@ -4,11 +4,12 @@ import ( "fmt" "strings" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/incremental" - "github.com/microsoft/typescript-go/internal/json" + "github.com/microsoft/typescript-go/internal/jsonutil" ) type readableBuildInfo struct { @@ -192,7 +193,7 @@ func toReadableBuildInfo(buildInfo *incremental.BuildInfo, buildInfoText string) readable.setEmitDiagnostics() readable.setAffectedFilesPendingEmit() readable.setEmitSignatures() - contents, err := json.MarshalIndent(&readable, "", " ") + contents, err := jsonutil.MarshalIndent(&readable, "", " ") if err != nil { panic("readableBuildInfo: failed to marshal readable build info: " + err.Error()) } diff --git a/internal/testutil/jstest/node.go b/internal/testutil/jstest/node.go index da1b911691..4eb3cd29b4 100644 --- a/internal/testutil/jstest/node.go +++ b/internal/testutil/jstest/node.go @@ -8,7 +8,7 @@ import ( "sync" "testing" - "github.com/microsoft/typescript-go/internal/json" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/repo" "github.com/microsoft/typescript-go/internal/tspath" ) diff --git a/internal/testutil/tsbaseline/sourcemap_baseline.go b/internal/testutil/tsbaseline/sourcemap_baseline.go index 4c83c3a920..903c189dee 100644 --- a/internal/testutil/tsbaseline/sourcemap_baseline.go +++ b/internal/testutil/tsbaseline/sourcemap_baseline.go @@ -7,8 +7,8 @@ import ( "strings" "testing" + "github.com/go-json-experiment/json" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/sourcemap" "github.com/microsoft/typescript-go/internal/testutil/baseline" "github.com/microsoft/typescript-go/internal/testutil/harnessutil" diff --git a/internal/tsoptions/commandlineparser_test.go b/internal/tsoptions/commandlineparser_test.go index 53bfc82792..fcd1e780c3 100644 --- a/internal/tsoptions/commandlineparser_test.go +++ b/internal/tsoptions/commandlineparser_test.go @@ -6,11 +6,11 @@ import ( "strings" "testing" + "github.com/go-json-experiment/json" "github.com/google/go-cmp/cmp/cmpopts" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/diagnosticwriter" - "github.com/microsoft/typescript-go/internal/json" "github.com/microsoft/typescript-go/internal/repo" "github.com/microsoft/typescript-go/internal/testutil/baseline" "github.com/microsoft/typescript-go/internal/testutil/filefixture" diff --git a/internal/tsoptions/tsconfigparsing_test.go b/internal/tsoptions/tsconfigparsing_test.go index be17ecdd1b..f3a9989e4e 100644 --- a/internal/tsoptions/tsconfigparsing_test.go +++ b/internal/tsoptions/tsconfigparsing_test.go @@ -12,7 +12,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnosticwriter" - "github.com/microsoft/typescript-go/internal/json" + "github.com/microsoft/typescript-go/internal/jsonutil" "github.com/microsoft/typescript-go/internal/parser" "github.com/microsoft/typescript-go/internal/repo" "github.com/microsoft/typescript-go/internal/testutil/baseline" @@ -850,13 +850,13 @@ func baselineParseConfigWith(t *testing.T, baselineFileName string, noSubmoduleB baselineContent.WriteString("configFileName:: " + config.configFileName + "\n") if noSubmoduleBaseline { baselineContent.WriteString("CompilerOptions::\n") - assert.NilError(t, json.MarshalIndentWrite(&baselineContent, parsedConfigFileContent.ParsedConfig.CompilerOptions, "", " ")) + assert.NilError(t, jsonutil.MarshalIndentWrite(&baselineContent, parsedConfigFileContent.ParsedConfig.CompilerOptions, "", " ")) baselineContent.WriteString("\n") baselineContent.WriteString("\n") if parsedConfigFileContent.ParsedConfig.TypeAcquisition != nil { baselineContent.WriteString("TypeAcquisition::\n") - assert.NilError(t, json.MarshalIndentWrite(&baselineContent, parsedConfigFileContent.ParsedConfig.TypeAcquisition, "", " ")) + assert.NilError(t, jsonutil.MarshalIndentWrite(&baselineContent, parsedConfigFileContent.ParsedConfig.TypeAcquisition, "", " ")) baselineContent.WriteString("\n") baselineContent.WriteString("\n") } @@ -884,7 +884,7 @@ func baselineParseConfigWith(t *testing.T, baselineFileName string, noSubmoduleB } func writeJsonReadableText(output io.Writer, input any) error { - return json.MarshalIndentWrite(output, input, "", " ") + return jsonutil.MarshalIndentWrite(output, input, "", " ") } func TestParseTypeAcquisition(t *testing.T) {