Skip to content

Commit 5892b56

Browse files
committed
Test output not found built error
1 parent ca72b95 commit 5892b56

File tree

6 files changed

+70
-5
lines changed

6 files changed

+70
-5
lines changed

internal/compiler/host.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ func (h *compilerHost) Trace(msg string) {
9191
}
9292

9393
func (h *compilerHost) GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget) *ast.SourceFile {
94-
text, _ := h.FS().ReadFile(fileName)
94+
text, ok := h.FS().ReadFile(fileName)
95+
if !ok {
96+
return nil
97+
}
9598
if tspath.FileExtensionIs(fileName, tspath.ExtensionJson) {
9699
return parser.ParseJSONText(fileName, path, text)
97100
}

internal/compiler/program.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ func (p *Program) initCheckerPool() {
244244
}
245245

246246
func canReplaceFileInProgram(file1 *ast.SourceFile, file2 *ast.SourceFile) bool {
247-
return file1.FileName() == file2.FileName() &&
247+
return file2 != nil &&
248+
file1.FileName() == file2.FileName() &&
248249
file1.Path() == file2.Path() &&
249250
file1.LanguageVersion == file2.LanguageVersion &&
250251
file1.LanguageVariant == file2.LanguageVariant &&

internal/execute/tscprojectreferences_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ func TestProjectReferences(t *testing.T) {
1515
}
1616

1717
cases := []tscInput{
18+
// !!! sheetal todo verifyCompilerOptions - check for noEmit
1819
{
1920
subScenario: "when project references composite project with noEmit",
2021
sys: newTestSys(FileMap{
@@ -51,6 +52,24 @@ func TestProjectReferences(t *testing.T) {
5152
"references": [
5253
{ "path": "../utils" },
5354
],
55+
}`,
56+
}, "/home/src/workspaces/solution"),
57+
commandLineArgs: []string{"--p", "project"},
58+
},
59+
{
60+
subScenario: "when project reference is not built",
61+
sys: newTestSys(FileMap{
62+
"/home/src/workspaces/solution/utils/index.ts": "export const x = 10;",
63+
"/home/src/workspaces/solution/utils/tsconfig.json": `{
64+
"compilerOptions": {
65+
"composite": true,
66+
},
67+
}`,
68+
"/home/src/workspaces/solution/project/index.ts": `import { x } from "../utils";`,
69+
"/home/src/workspaces/solution/project/tsconfig.json": `{
70+
"references": [
71+
{ "path": "../utils" },
72+
],
5473
}`,
5574
}, "/home/src/workspaces/solution"),
5675
commandLineArgs: []string{"--p", "project"},

testdata/baselines/reference/tsc/commandLine/Parse-enum-type-options.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,4 @@ ParsedCommandLine::{
4343
"compileOnSave": null
4444
}
4545
Output::
46-
//// [/home/src/workspaces/project/first.js] new file
47-
4846

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
currentDirectory::/home/src/workspaces/solution
3+
useCaseSensitiveFileNames::true
4+
Input::--p project
5+
//// [/home/src/workspaces/solution/project/index.ts] new file
6+
import { x } from "../utils";
7+
//// [/home/src/workspaces/solution/project/tsconfig.json] new file
8+
{
9+
"references": [
10+
{ "path": "../utils" },
11+
],
12+
}
13+
//// [/home/src/workspaces/solution/utils/index.ts] new file
14+
export const x = 10;
15+
//// [/home/src/workspaces/solution/utils/tsconfig.json] new file
16+
{
17+
"compilerOptions": {
18+
"composite": true,
19+
},
20+
}
21+
22+
ExitStatus:: 2
23+
24+
CompilerOptions::{
25+
"project": "/home/src/workspaces/solution/project"
26+
}
27+
Output::
28+
project/index.ts:1:19 - error TS6305: Output file '/home/src/workspaces/solution/utils/index.d.ts' has not been built from source file '/home/src/workspaces/solution/utils/index.ts'.
29+
30+
1 import { x } from "../utils";
31+
   ~~~~~~~~~~
32+
33+
34+
Found 1 error in project/index.ts:1
35+
36+
//// [/home/src/workspaces/solution/project/index.js] new file
37+
"use strict";
38+
Object.defineProperty(exports, "__esModule", { value: true });
39+
40+
//// [/home/src/workspaces/solution/project/index.ts] no change
41+
//// [/home/src/workspaces/solution/project/tsconfig.json] no change
42+
//// [/home/src/workspaces/solution/utils/index.ts] no change
43+
//// [/home/src/workspaces/solution/utils/tsconfig.json] no change
44+

testdata/baselines/reference/tsc/projectReferences/when-project-references-composite-project-with-noEmit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ CompilerOptions::{
2626
"project": "/home/src/workspaces/solution/project"
2727
}
2828
Output::
29-
[96mproject/index.ts[0m:[93m1[0m:[93m19[0m - [91merror[0m[90m TS2306: [0mFile '/home/src/workspaces/solution/utils/index.d.ts' is not a module.
29+
[96mproject/index.ts[0m:[93m1[0m:[93m19[0m - [91merror[0m[90m TS6305: [0mOutput file '/home/src/workspaces/solution/utils/index.d.ts' has not been built from source file '/home/src/workspaces/solution/utils/index.ts'.
3030

3131
1 import { x } from "../utils";
3232
   ~~~~~~~~~~

0 commit comments

Comments
 (0)