Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion internal/compiler/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/compiler/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
5 changes: 4 additions & 1 deletion internal/testutil/harnessutil/harnessutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
/// <reference path="invalid.ts" />
var x = 0;

//// [invalid.js]
//// [declarationEmitInvalidReference.js]
/// <reference path="invalid.ts" />
var x = 0;


//// [invalid.d.ts]
//// [declarationEmitInvalidReference.d.ts]
declare var x: number;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
/// <reference path="invalid.ts" />
var x = 0;

//// [invalid.js]
//// [declarationEmitInvalidReference2.js]
/// <reference path="invalid.ts" />
var x = 0;


//// [invalid.d.ts]
//// [declarationEmitInvalidReference2.d.ts]
declare var x: number;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/// <reference path="./file1" />
//// [file1.js]
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
"use strict";
-/// <reference path="./file1" />
Object.defineProperty(exports, "__esModule", { value: true });
+/// <reference path="./file1" />
+//// [file1.js]
+/// <reference path="./file1" />
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/// <reference path="./file1" />
//// [file1.js]
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
"use strict";
-/// <reference path="./file1" />
Object.defineProperty(exports, "__esModule", { value: true });
+/// <reference path="./file1" />
+//// [file1.js]
+/// <reference path="./file1" />
Original file line number Diff line number Diff line change
Expand Up @@ -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]
/// <reference path='filedoesnotexist.ts'/>
/// <reference path='otherdoesnotexist.d.ts'/>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ import moment = require("moment-timezone");
//// [idx.test.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//// [idx.js]
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
//// [idx.test.js]
"use strict";
-/// <reference path="./idx" />
Object.defineProperty(exports, "__esModule", { value: true });
+//// [idx.js]
Object.defineProperty(exports, "__esModule", { value: true });
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class selfReferencingFile2 {

}

//// [selfReferencingFile2.js]
//// [selfReferencingFile2.js]
///<reference path='../selfReferencingFile2.ts'/>
class selfReferencingFile2 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
--- old.selfReferencingFile2.js
+++ new.selfReferencingFile2.js
@@= skipped -7, +7 lines =@@
}
@@= skipped -8, +8 lines =@@

//// [selfReferencingFile2.js]
+//// [selfReferencingFile2.js]
///<reference path='../selfReferencingFile2.ts'/>
-var selfReferencingFile2 = /** @class */ (function () {
- function selfReferencingFile2() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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 =@@
///<reference path='typescript.ts' />
var TypeScript;
(function (TypeScript) {
Expand All @@ -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 = {}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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 =@@
///<reference path='typescript.ts' />
var TypeScript;
(function (TypeScript) {
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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 =@@
///<reference path='typescript.ts' />
var TypeScript;
(function (TypeScript) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading