From f9376677a8d934cd503cc2725f89939f1acca83d Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 10 Jun 2025 01:23:52 -0700 Subject: [PATCH 1/3] Do not create SourceFiles for non-existent files --- internal/compiler/host.go | 5 ++++- internal/testutil/harnessutil/harnessutil.go | 5 ++++- .../compiler/declarationEmitInvalidReference.js | 2 -- .../declarationEmitInvalidReference.js.diff | 15 --------------- .../compiler/declarationEmitInvalidReference2.js | 2 -- .../declarationEmitInvalidReference2.js.diff | 15 --------------- .../compiler/duplicateIdentifierRelatedSpans6.js | 1 - .../duplicateIdentifierRelatedSpans6.js.diff | 3 +-- .../compiler/duplicateIdentifierRelatedSpans7.js | 1 - .../duplicateIdentifierRelatedSpans7.js.diff | 3 +-- .../compiler/invalidTripleSlashReference.js | 1 - .../compiler/invalidTripleSlashReference.js.diff | 10 ---------- ...duleAugmentationDuringSyntheticDefaultCheck.js | 1 - ...ugmentationDuringSyntheticDefaultCheck.js.diff | 3 +-- .../submodule/compiler/selfReferencingFile2.js | 1 - .../compiler/selfReferencingFile2.js.diff | 4 +--- .../submodule/conformance/parserRealSource1.js | 1 - .../conformance/parserRealSource1.js.diff | 11 ++--------- .../submodule/conformance/parserRealSource10.js | 1 - .../conformance/parserRealSource10.js.diff | 8 ++------ .../submodule/conformance/parserRealSource11.js | 1 - .../conformance/parserRealSource11.js.diff | 8 ++------ .../submodule/conformance/parserRealSource12.js | 1 - .../conformance/parserRealSource12.js.diff | 11 ++--------- .../submodule/conformance/parserRealSource13.js | 1 - .../conformance/parserRealSource13.js.diff | 9 +-------- .../submodule/conformance/parserRealSource14.js | 1 - .../conformance/parserRealSource14.js.diff | 10 +--------- .../submodule/conformance/parserRealSource2.js | 1 - .../conformance/parserRealSource2.js.diff | 10 +--------- .../submodule/conformance/parserRealSource3.js | 1 - .../conformance/parserRealSource3.js.diff | 10 +--------- .../submodule/conformance/parserRealSource4.js | 1 - .../conformance/parserRealSource4.js.diff | 11 ++--------- .../submodule/conformance/parserRealSource5.js | 1 - .../conformance/parserRealSource5.js.diff | 10 +--------- .../submodule/conformance/parserRealSource6.js | 1 - .../conformance/parserRealSource6.js.diff | 11 ++--------- .../submodule/conformance/parserRealSource7.js | 1 - .../conformance/parserRealSource7.js.diff | 11 ++--------- .../submodule/conformance/parserRealSource8.js | 1 - .../conformance/parserRealSource8.js.diff | 11 ++--------- .../submodule/conformance/parserRealSource9.js | 1 - .../conformance/parserRealSource9.js.diff | 11 ++--------- .../submodule/conformance/parserharness.js | 4 ---- .../submodule/conformance/parserharness.js.diff | 9 ++------- .../submodule/conformance/parserindenter.js | 1 - .../submodule/conformance/parserindenter.js.diff | 10 +--------- .../submodule/conformance/scannertest1.js | 1 - .../submodule/conformance/scannertest1.js.diff | 5 +---- .../tsc/commandLine/Parse-enum-type-options.js | 2 -- 51 files changed, 39 insertions(+), 221 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference2.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/invalidTripleSlashReference.js.diff diff --git a/internal/compiler/host.go b/internal/compiler/host.go index 3db76b350a..eb674e7bce 100644 --- a/internal/compiler/host.go +++ b/internal/compiler/host.go @@ -74,7 +74,10 @@ func (h *compilerHost) Trace(msg string) { } func (h *compilerHost) GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget) *ast.SourceFile { - text, _ := h.FS().ReadFile(fileName) + text, ok := h.FS().ReadFile(fileName) + if !ok { + return nil + } if tspath.FileExtensionIs(fileName, tspath.ExtensionJson) { return parser.ParseJSONText(fileName, path, text) } diff --git a/internal/testutil/harnessutil/harnessutil.go b/internal/testutil/harnessutil/harnessutil.go index 3d66dfb0de..a8284ff6dd 100644 --- a/internal/testutil/harnessutil/harnessutil.go +++ b/internal/testutil/harnessutil/harnessutil.go @@ -497,7 +497,10 @@ func GetSourceFileCacheKey( } func (h *cachedCompilerHost) GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget) *ast.SourceFile { - text, _ := h.FS().ReadFile(fileName) + text, ok := h.FS().ReadFile(fileName) + if !ok { + return nil + } key := GetSourceFileCacheKey( *h.options.SourceFileAffecting(), diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference.js b/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference.js index dc34c2ad89..21529f328f 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference.js @@ -4,12 +4,10 @@ /// var x = 0; -//// [invalid.js] //// [declarationEmitInvalidReference.js] /// var x = 0; -//// [invalid.d.ts] //// [declarationEmitInvalidReference.d.ts] declare var x: number; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference.js.diff deleted file mode 100644 index b3796846f7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference.js.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.declarationEmitInvalidReference.js -+++ new.declarationEmitInvalidReference.js -@@= skipped -3, +3 lines =@@ - /// - var x = 0; - -+//// [invalid.js] - //// [declarationEmitInvalidReference.js] - /// - var x = 0; - - -+//// [invalid.d.ts] - //// [declarationEmitInvalidReference.d.ts] - declare var x: number; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference2.js b/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference2.js index a81d79f9c9..200c14c6cc 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference2.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference2.js @@ -4,12 +4,10 @@ /// var x = 0; -//// [invalid.js] //// [declarationEmitInvalidReference2.js] /// var x = 0; -//// [invalid.d.ts] //// [declarationEmitInvalidReference2.d.ts] declare var x: number; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference2.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference2.js.diff deleted file mode 100644 index fd43653605..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference2.js.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.declarationEmitInvalidReference2.js -+++ new.declarationEmitInvalidReference2.js -@@= skipped -3, +3 lines =@@ - /// - var x = 0; - -+//// [invalid.js] - //// [declarationEmitInvalidReference2.js] - /// - var x = 0; - - -+//// [invalid.d.ts] - //// [declarationEmitInvalidReference2.d.ts] - declare var x: number; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js index 30f69da3bb..67ad695067 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js +++ b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js @@ -25,4 +25,3 @@ export {}; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /// -//// [file1.js] diff --git a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff index 046347190b..ce53729873 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff +++ b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff @@ -9,5 +9,4 @@ "use strict"; -/// Object.defineProperty(exports, "__esModule", { value: true }); -+/// -+//// [file1.js] \ No newline at end of file ++/// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js index 0fa26ee885..634eac5395 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js +++ b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js @@ -37,4 +37,3 @@ export {}; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /// -//// [file1.js] diff --git a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff index 05309d2669..9009fe87ce 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff +++ b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff @@ -9,5 +9,4 @@ "use strict"; -/// Object.defineProperty(exports, "__esModule", { value: true }); -+/// -+//// [file1.js] \ No newline at end of file ++/// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/invalidTripleSlashReference.js b/testdata/baselines/reference/submodule/compiler/invalidTripleSlashReference.js index dd50c5dab1..8577c69d7b 100644 --- a/testdata/baselines/reference/submodule/compiler/invalidTripleSlashReference.js +++ b/testdata/baselines/reference/submodule/compiler/invalidTripleSlashReference.js @@ -7,7 +7,6 @@ // this test doesn't actually give the errors you want due to the way the compiler reports errors var x = 1; -//// [filedoesnotexist.js] //// [invalidTripleSlashReference.js] /// /// diff --git a/testdata/baselines/reference/submodule/compiler/invalidTripleSlashReference.js.diff b/testdata/baselines/reference/submodule/compiler/invalidTripleSlashReference.js.diff deleted file mode 100644 index 43208a6365..0000000000 --- a/testdata/baselines/reference/submodule/compiler/invalidTripleSlashReference.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.invalidTripleSlashReference.js -+++ new.invalidTripleSlashReference.js -@@= skipped -6, +6 lines =@@ - // this test doesn't actually give the errors you want due to the way the compiler reports errors - var x = 1; - -+//// [filedoesnotexist.js] - //// [invalidTripleSlashReference.js] - /// - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js b/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js index a4e8274314..1de091ed9e 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js +++ b/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js @@ -37,4 +37,3 @@ import moment = require("moment-timezone"); //// [idx.test.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -//// [idx.js] diff --git a/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js.diff b/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js.diff index f40fac8d78..74cfebc2a4 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js.diff +++ b/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js.diff @@ -10,5 +10,4 @@ //// [idx.test.js] "use strict"; -/// - Object.defineProperty(exports, "__esModule", { value: true }); -+//// [idx.js] \ No newline at end of file + Object.defineProperty(exports, "__esModule", { value: true }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/selfReferencingFile2.js b/testdata/baselines/reference/submodule/compiler/selfReferencingFile2.js index 03e49a543b..09617bc1f0 100644 --- a/testdata/baselines/reference/submodule/compiler/selfReferencingFile2.js +++ b/testdata/baselines/reference/submodule/compiler/selfReferencingFile2.js @@ -7,7 +7,6 @@ class selfReferencingFile2 { } -//// [selfReferencingFile2.js] //// [selfReferencingFile2.js] /// class selfReferencingFile2 { diff --git a/testdata/baselines/reference/submodule/compiler/selfReferencingFile2.js.diff b/testdata/baselines/reference/submodule/compiler/selfReferencingFile2.js.diff index 2d3f26fb76..ca539e0b3f 100644 --- a/testdata/baselines/reference/submodule/compiler/selfReferencingFile2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/selfReferencingFile2.js.diff @@ -1,10 +1,8 @@ --- old.selfReferencingFile2.js +++ new.selfReferencingFile2.js -@@= skipped -7, +7 lines =@@ - } +@@= skipped -8, +8 lines =@@ //// [selfReferencingFile2.js] -+//// [selfReferencingFile2.js] /// -var selfReferencingFile2 = /** @class */ (function () { - function selfReferencingFile2() { diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource1.js b/testdata/baselines/reference/submodule/conformance/parserRealSource1.js index 31be2ea5a3..812cd5d221 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource1.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource1.js @@ -156,7 +156,6 @@ module TypeScript { } -//// [typescript.js] //// [parserRealSource1.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource1.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource1.js.diff index 255b042dc2..cce7b8f187 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource1.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource1.js.diff @@ -1,13 +1,6 @@ --- old.parserRealSource1.js +++ new.parserRealSource1.js -@@= skipped -155, +155 lines =@@ - } - - -+//// [typescript.js] - //// [parserRealSource1.js] - // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. - // See LICENSE.txt in the project root for complete license information. +@@= skipped -161, +161 lines =@@ /// var TypeScript; (function (TypeScript) { @@ -16,7 +9,7 @@ (function (CompilerDiagnostics) { CompilerDiagnostics.debug = false; CompilerDiagnostics.diagnosticWriter = null; -@@= skipped -32, +33 lines =@@ +@@= skipped -26, +26 lines =@@ } CompilerDiagnostics.assert = assert; })(CompilerDiagnostics = TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource10.js b/testdata/baselines/reference/submodule/conformance/parserRealSource10.js index 0067dc7431..21cec68e33 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource10.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource10.js @@ -457,7 +457,6 @@ module TypeScript { } } -//// [typescript.js] //// [parserRealSource10.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource10.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource10.js.diff index 1e185f7794..b5278cc69c 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource10.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource10.js.diff @@ -1,10 +1,6 @@ --- old.parserRealSource10.js +++ new.parserRealSource10.js -@@= skipped -456, +456 lines =@@ - } - } - -+//// [typescript.js] +@@= skipped -459, +459 lines =@@ //// [parserRealSource10.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. @@ -31,7 +27,7 @@ (function (TokenID) { // Keywords TokenID[TokenID["Any"] = 0] = "Any"; -@@= skipped -157, +143 lines =@@ +@@= skipped -154, +139 lines =@@ TypeScript.noRegexTable[TokenID.CloseBrace] = true; TypeScript.noRegexTable[TokenID.True] = true; TypeScript.noRegexTable[TokenID.False] = true; diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource11.js b/testdata/baselines/reference/submodule/conformance/parserRealSource11.js index 9b06fcfa42..0dea182bab 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource11.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource11.js @@ -2366,7 +2366,6 @@ module TypeScript { } } -//// [typescript.js] //// [parserRealSource11.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource11.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource11.js.diff index 7f0c079f3e..56a824f748 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource11.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource11.js.diff @@ -1,10 +1,6 @@ --- old.parserRealSource11.js +++ new.parserRealSource11.js -@@= skipped -2365, +2365 lines =@@ - } - } - -+//// [typescript.js] +@@= skipped -2368, +2368 lines =@@ //// [parserRealSource11.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. @@ -77,7 +73,7 @@ switch (this.nodeType) { case NodeType.Error: case NodeType.EmptyExpr: -@@= skipped -73, +55 lines =@@ +@@= skipped -70, +51 lines =@@ throw new Error("please implement in derived class"); } return this; diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource12.js b/testdata/baselines/reference/submodule/conformance/parserRealSource12.js index 032a01fda1..827bd1e405 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource12.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource12.js @@ -532,7 +532,6 @@ module TypeScript { } } -//// [typescript.js] //// [parserRealSource12.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource12.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource12.js.diff index 984f440591..4ac61695aa 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource12.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource12.js.diff @@ -1,13 +1,6 @@ --- old.parserRealSource12.js +++ new.parserRealSource12.js -@@= skipped -531, +531 lines =@@ - } - } - -+//// [typescript.js] - //// [parserRealSource12.js] - // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. - // See LICENSE.txt in the project root for complete license information. +@@= skipped -537, +537 lines =@@ /// var TypeScript; (function (TypeScript) { @@ -52,7 +45,7 @@ var preAst = this.pre(ast, parent, this); if (preAst === undefined) { preAst = ast; -@@= skipped -54, +56 lines =@@ +@@= skipped -48, +49 lines =@@ else { return preAst; } diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource13.js b/testdata/baselines/reference/submodule/conformance/parserRealSource13.js index 68436f8090..1be9d1eacc 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource13.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource13.js @@ -148,7 +148,6 @@ module TypeScript.AstWalkerWithDetailCallback { } } -//// [typescript.js] //// [parserRealSource13.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource13.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource13.js.diff index eb3ba7a5f5..f7b81d1ebd 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource13.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource13.js.diff @@ -1,13 +1,6 @@ --- old.parserRealSource13.js +++ new.parserRealSource13.js -@@= skipped -147, +147 lines =@@ - } - } - -+//// [typescript.js] - //// [parserRealSource13.js] - // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. - // See LICENSE.txt in the project root for complete license information. +@@= skipped -153, +153 lines =@@ /// var TypeScript; (function (TypeScript) { diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource14.js b/testdata/baselines/reference/submodule/conformance/parserRealSource14.js index 0cb4be9564..cbc53d013e 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource14.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource14.js @@ -577,7 +577,6 @@ module TypeScript { } -//// [typescript.js] //// [parserRealSource14.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource14.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource14.js.diff index 1910e1a4f9..fbf2b330b9 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource14.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource14.js.diff @@ -1,14 +1,6 @@ --- old.parserRealSource14.js +++ new.parserRealSource14.js -@@= skipped -576, +576 lines =@@ - } - - -+//// [typescript.js] - //// [parserRealSource14.js] - // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. - // See LICENSE.txt in the project root for complete license information. -@@= skipped -22, +23 lines =@@ +@@= skipped -598, +598 lines =@@ // Helper class representing a path from a root ast node to a (grand)child ast node. // This is helpful as our tree don't have parents. // diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource2.js b/testdata/baselines/reference/submodule/conformance/parserRealSource2.js index 4a64fc6bba..b0594a7367 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource2.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource2.js @@ -273,7 +273,6 @@ module TypeScript { } -//// [typescript.js] //// [parserRealSource2.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource2.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource2.js.diff index 79a3057ef7..a487c36145 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource2.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource2.js.diff @@ -1,14 +1,6 @@ --- old.parserRealSource2.js +++ new.parserRealSource2.js -@@= skipped -272, +272 lines =@@ - - } - -+//// [typescript.js] - //// [parserRealSource2.js] - // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. - // See LICENSE.txt in the project root for complete license information. -@@= skipped -10, +11 lines =@@ +@@= skipped -282, +282 lines =@@ return (val & flag) != 0; } TypeScript.hasFlag = hasFlag; diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource3.js b/testdata/baselines/reference/submodule/conformance/parserRealSource3.js index 58c19fce49..93737f45a8 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource3.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource3.js @@ -121,7 +121,6 @@ module TypeScript { } } -//// [typescript.js] //// [parserRealSource3.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource3.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource3.js.diff index 10fd32cc60..b11d0314f4 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource3.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource3.js.diff @@ -1,14 +1,6 @@ --- old.parserRealSource3.js +++ new.parserRealSource3.js -@@= skipped -120, +120 lines =@@ - } - } - -+//// [typescript.js] - //// [parserRealSource3.js] - // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. - // See LICENSE.txt in the project root for complete license information. -@@= skipped -7, +8 lines =@@ +@@= skipped -127, +127 lines =@@ var TypeScript; (function (TypeScript) { // Note: Any addition to the NodeType should also be supported with addition to AstWalkerDetailCallback diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource4.js b/testdata/baselines/reference/submodule/conformance/parserRealSource4.js index d4fe1ba53f..564aaa2882 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource4.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource4.js @@ -297,7 +297,6 @@ module TypeScript { } -//// [typescript.js] //// [parserRealSource4.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource4.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource4.js.diff index e979426734..951db9e31f 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource4.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource4.js.diff @@ -1,13 +1,6 @@ --- old.parserRealSource4.js +++ new.parserRealSource4.js -@@= skipped -296, +296 lines =@@ - - } - -+//// [typescript.js] - //// [parserRealSource4.js] - // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. - // See LICENSE.txt in the project root for complete license information. +@@= skipped -302, +302 lines =@@ /// var TypeScript; (function (TypeScript) { @@ -49,7 +42,7 @@ var result = []; for (var k in this.table) { if (this.table[k] != undefined) { -@@= skipped -34, +32 lines =@@ +@@= skipped -28, +25 lines =@@ } } return result; diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource5.js b/testdata/baselines/reference/submodule/conformance/parserRealSource5.js index 4e617100fe..66f6cfb368 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource5.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource5.js @@ -68,7 +68,6 @@ module TypeScript { } } -//// [typescript.js] //// [parserRealSource5.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource5.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource5.js.diff index 156ac90886..4500306d2b 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource5.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource5.js.diff @@ -1,14 +1,6 @@ --- old.parserRealSource5.js +++ new.parserRealSource5.js -@@= skipped -67, +67 lines =@@ - } - } - -+//// [typescript.js] - //// [parserRealSource5.js] - // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. - // See LICENSE.txt in the project root for complete license information. -@@= skipped -7, +8 lines =@@ +@@= skipped -74, +74 lines =@@ var TypeScript; (function (TypeScript) { // TODO: refactor indent logic for use in emit diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource6.js b/testdata/baselines/reference/submodule/conformance/parserRealSource6.js index 22be1bc9e4..9b7c3d0bda 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource6.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource6.js @@ -223,7 +223,6 @@ module TypeScript { } } -//// [typescript.js] //// [parserRealSource6.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource6.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource6.js.diff index 5521a99577..70d371a70d 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource6.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource6.js.diff @@ -1,13 +1,6 @@ --- old.parserRealSource6.js +++ new.parserRealSource6.js -@@= skipped -222, +222 lines =@@ - } - } - -+//// [typescript.js] - //// [parserRealSource6.js] - // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. - // See LICENSE.txt in the project root for complete license information. +@@= skipped -228, +228 lines =@@ /// var TypeScript; (function (TypeScript) { @@ -117,7 +110,7 @@ if (this.scriptFragment == null) { var ast = this.getScriptFragmentStartAST(); var minChar = ast.minChar; -@@= skipped -70, +81 lines =@@ +@@= skipped -64, +74 lines =@@ this.scriptFragment = TypeScript.quickParse(this.logger, ast, this.text, minChar, limChar, null /*errorCapture*/).Script; } return this.scriptFragment; diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource7.js b/testdata/baselines/reference/submodule/conformance/parserRealSource7.js index c53667c51a..c64dbc885f 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource7.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource7.js @@ -835,7 +835,6 @@ module TypeScript { } -//// [typescript.js] //// [parserRealSource7.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource7.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource7.js.diff index 7bccaf24ee..579b94c117 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource7.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource7.js.diff @@ -1,13 +1,6 @@ --- old.parserRealSource7.js +++ new.parserRealSource7.js -@@= skipped -834, +834 lines =@@ - - } - -+//// [typescript.js] - //// [parserRealSource7.js] - // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. - // See LICENSE.txt in the project root for complete license information. +@@= skipped -840, +840 lines =@@ /// var TypeScript; (function (TypeScript) { @@ -26,7 +19,7 @@ TypeScript.Continuation = Continuation; function getBaseTypeLinks(bases, baseTypeLinks) { if (bases) { -@@= skipped -86, +87 lines =@@ +@@= skipped -80, +80 lines =@@ case NodeType.Name: var name = alias.text; var isDynamic = isQuoted(name); diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource8.js b/testdata/baselines/reference/submodule/conformance/parserRealSource8.js index ea9f8a75f8..7a625e2058 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource8.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource8.js @@ -468,7 +468,6 @@ module TypeScript { } } -//// [typescript.js] //// [parserRealSource8.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource8.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource8.js.diff index f3dfc53da1..2973317178 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource8.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource8.js.diff @@ -1,13 +1,6 @@ --- old.parserRealSource8.js +++ new.parserRealSource8.js -@@= skipped -467, +467 lines =@@ - } - } - -+//// [typescript.js] - //// [parserRealSource8.js] - // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. - // See LICENSE.txt in the project root for complete license information. +@@= skipped -473, +473 lines =@@ /// var TypeScript; (function (TypeScript) { @@ -28,7 +21,7 @@ TypeScript.AssignScopeContext = AssignScopeContext; function pushAssignScope(scope, context, type, classType, fnc) { var chain = new ScopeChain(null, context.scopeChain, scope); -@@= skipped -40, +43 lines =@@ +@@= skipped -34, +36 lines =@@ return s.isInstanceProperty(); } TypeScript.instanceFilterStop = instanceFilterStop; diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource9.js b/testdata/baselines/reference/submodule/conformance/parserRealSource9.js index 95eb760ffe..6bdf262ed9 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource9.js +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource9.js @@ -211,7 +211,6 @@ module TypeScript { } -//// [typescript.js] //// [parserRealSource9.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. diff --git a/testdata/baselines/reference/submodule/conformance/parserRealSource9.js.diff b/testdata/baselines/reference/submodule/conformance/parserRealSource9.js.diff index 85c34abfe6..6baa7fc955 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRealSource9.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserRealSource9.js.diff @@ -1,13 +1,6 @@ --- old.parserRealSource9.js +++ new.parserRealSource9.js -@@= skipped -210, +210 lines =@@ - - } - -+//// [typescript.js] - //// [parserRealSource9.js] - // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. - // See LICENSE.txt in the project root for complete license information. +@@= skipped -216, +216 lines =@@ /// var TypeScript; (function (TypeScript) { @@ -23,7 +16,7 @@ var extendsList = null; if (typeLinks) { extendsList = new Type[]; -@@= skipped -28, +30 lines =@@ +@@= skipped -22, +23 lines =@@ } } return extendsList; diff --git a/testdata/baselines/reference/submodule/conformance/parserharness.js b/testdata/baselines/reference/submodule/conformance/parserharness.js index b1c2180b43..73f7b248c9 100644 --- a/testdata/baselines/reference/submodule/conformance/parserharness.js +++ b/testdata/baselines/reference/submodule/conformance/parserharness.js @@ -2083,10 +2083,6 @@ module Harness { } -//// [io.js] -//// [typescript.js] -//// [typescriptServices.js] -//// [diff.js] //// [parserharness.js] /// /// diff --git a/testdata/baselines/reference/submodule/conformance/parserharness.js.diff b/testdata/baselines/reference/submodule/conformance/parserharness.js.diff index e310aa2c0d..1ec21dce2d 100644 --- a/testdata/baselines/reference/submodule/conformance/parserharness.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserharness.js.diff @@ -1,13 +1,8 @@ --- old.parserharness.js +++ new.parserharness.js -@@= skipped -2082, +2082 lines =@@ - } +@@= skipped -2083, +2083 lines =@@ -+//// [io.js] -+//// [typescript.js] -+//// [typescriptServices.js] -+//// [diff.js] //// [parserharness.js] -// -// Copyright (c) Microsoft Corporation. All rights reserved. @@ -41,7 +36,7 @@ /// /// /// -@@= skipped -62, +37 lines =@@ +@@= skipped -61, +32 lines =@@ var global = Function("return this").call(null); Harness.usePull = false; // Assert functions diff --git a/testdata/baselines/reference/submodule/conformance/parserindenter.js b/testdata/baselines/reference/submodule/conformance/parserindenter.js index 390728f95a..2b0e235972 100644 --- a/testdata/baselines/reference/submodule/conformance/parserindenter.js +++ b/testdata/baselines/reference/submodule/conformance/parserindenter.js @@ -743,7 +743,6 @@ module Formatting { } -//// [formatting.js] //// [parserindenter.js] // // Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/testdata/baselines/reference/submodule/conformance/parserindenter.js.diff b/testdata/baselines/reference/submodule/conformance/parserindenter.js.diff index 9c31907c0d..d04ce396f0 100644 --- a/testdata/baselines/reference/submodule/conformance/parserindenter.js.diff +++ b/testdata/baselines/reference/submodule/conformance/parserindenter.js.diff @@ -1,14 +1,6 @@ --- old.parserindenter.js +++ new.parserindenter.js -@@= skipped -742, +742 lines =@@ - } - - -+//// [formatting.js] - //// [parserindenter.js] - // - // Copyright (c) Microsoft Corporation. All rights reserved. -@@= skipped -18, +19 lines =@@ +@@= skipped -760, +760 lines =@@ /// var Formatting; (function (Formatting) { diff --git a/testdata/baselines/reference/submodule/conformance/scannertest1.js b/testdata/baselines/reference/submodule/conformance/scannertest1.js index 02c63c81ba..5833b804cb 100644 --- a/testdata/baselines/reference/submodule/conformance/scannertest1.js +++ b/testdata/baselines/reference/submodule/conformance/scannertest1.js @@ -26,7 +26,6 @@ class CharacterInfo { -//// [References.js] //// [scannertest1.js] /// class CharacterInfo { diff --git a/testdata/baselines/reference/submodule/conformance/scannertest1.js.diff b/testdata/baselines/reference/submodule/conformance/scannertest1.js.diff index 360aa2cfa2..80ac148354 100644 --- a/testdata/baselines/reference/submodule/conformance/scannertest1.js.diff +++ b/testdata/baselines/reference/submodule/conformance/scannertest1.js.diff @@ -1,10 +1,7 @@ --- old.scannertest1.js +++ new.scannertest1.js -@@= skipped -25, +25 lines =@@ +@@= skipped -27, +27 lines =@@ - - -+//// [References.js] //// [scannertest1.js] /// -var CharacterInfo = /** @class */ (function () { diff --git a/testdata/baselines/reference/tsc/commandLine/Parse-enum-type-options.js b/testdata/baselines/reference/tsc/commandLine/Parse-enum-type-options.js index 4cb17c49cd..40579d601f 100644 --- a/testdata/baselines/reference/tsc/commandLine/Parse-enum-type-options.js +++ b/testdata/baselines/reference/tsc/commandLine/Parse-enum-type-options.js @@ -43,6 +43,4 @@ ParsedCommandLine::{ "compileOnSave": null } Output:: -//// [/home/src/workspaces/project/first.js] new file - From 99a38d2ff66f823b659841a0cf78ae9fac41a844 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 10 Jun 2025 09:47:02 -0700 Subject: [PATCH 2/3] nil check --- internal/compiler/program.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/compiler/program.go b/internal/compiler/program.go index a5a8b96800..6099e627db 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -229,7 +229,7 @@ func NewProgram(opts ProgramOptions) *Program { func (p *Program) UpdateProgram(changedFilePath tspath.Path) (*Program, bool) { oldFile := p.filesByPath[changedFilePath] newFile := p.Host().GetSourceFile(oldFile.FileName(), changedFilePath, oldFile.LanguageVersion) - if !canReplaceFileInProgram(oldFile, newFile) { + if newFile == nil || !canReplaceFileInProgram(oldFile, newFile) { return NewProgram(p.opts), false } result := &Program{ From f0b3e6f8467f19aac364e39d7ad28a37664cc9d8 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 10 Jun 2025 10:02:11 -0700 Subject: [PATCH 3/3] Move nil check --- internal/compiler/program.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 6099e627db..0583933fd1 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -229,7 +229,7 @@ func NewProgram(opts ProgramOptions) *Program { func (p *Program) UpdateProgram(changedFilePath tspath.Path) (*Program, bool) { oldFile := p.filesByPath[changedFilePath] newFile := p.Host().GetSourceFile(oldFile.FileName(), changedFilePath, oldFile.LanguageVersion) - if newFile == nil || !canReplaceFileInProgram(oldFile, newFile) { + if !canReplaceFileInProgram(oldFile, newFile) { return NewProgram(p.opts), false } result := &Program{ @@ -262,7 +262,8 @@ func (p *Program) initCheckerPool() { } func canReplaceFileInProgram(file1 *ast.SourceFile, file2 *ast.SourceFile) bool { - return file1.FileName() == file2.FileName() && + return file2 != nil && + file1.FileName() == file2.FileName() && file1.Path() == file2.Path() && file1.LanguageVersion == file2.LanguageVersion && file1.LanguageVariant == file2.LanguageVariant &&