Skip to content

Commit 5ab1364

Browse files
authored
Fix nil host with watch and incremental (#1455)
1 parent b0ee8b4 commit 5ab1364

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

internal/execute/tscwatch_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ func TestWatch(t *testing.T) {
1515
},
1616
commandLineArgs: []string{"index.ts", "--watch"},
1717
},
18+
{
19+
subScenario: "watch with tsconfig and incremental",
20+
files: FileMap{
21+
"/home/src/workspaces/project/index.ts": "",
22+
"/home/src/workspaces/project/tsconfig.json": "{}",
23+
},
24+
commandLineArgs: []string{"--watch", "--incremental"},
25+
},
1826
}
1927

2028
for _, test := range testCases {

internal/execute/watcher.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ func createWatcher(sys System, configParseResult *tsoptions.ParsedCommandLine, r
4242
}
4343

4444
func (w *Watcher) start() {
45-
// if this function is updated, make sure to update `StartForTest` in export_test.go as needed
46-
if w.configFileName == "" {
47-
w.host = compiler.NewCompilerHost(w.sys.GetCurrentDirectory(), w.sys.FS(), w.sys.DefaultLibraryPath(), nil)
48-
}
45+
w.host = compiler.NewCompilerHost(w.sys.GetCurrentDirectory(), w.sys.FS(), w.sys.DefaultLibraryPath(), nil)
4946
w.program = incremental.ReadBuildInfoProgram(w.options, incremental.NewBuildInfoReader(w.host))
5047

5148
if !w.testing {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
currentDirectory::/home/src/workspaces/project
2+
useCaseSensitiveFileNames::true
3+
Input::
4+
//// [/home/src/workspaces/project/index.ts] *new*
5+
6+
//// [/home/src/workspaces/project/tsconfig.json] *new*
7+
{}
8+
9+
tsgo --watch --incremental
10+
ExitStatus:: Success
11+
Output::
12+
//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib*
13+
/// <reference no-default-lib="true"/>
14+
interface Boolean {}
15+
interface Function {}
16+
interface CallableFunction {}
17+
interface NewableFunction {}
18+
interface IArguments {}
19+
interface Number { toExponential: any; }
20+
interface Object {}
21+
interface RegExp {}
22+
interface String { charAt: any; }
23+
interface Array<T> { length: number; [n: number]: T; }
24+
interface ReadonlyArray<T> {}
25+
interface SymbolConstructor {
26+
(desc?: string | number): symbol;
27+
for(name: string): symbol;
28+
readonly toStringTag: symbol;
29+
}
30+
declare var Symbol: SymbolConstructor;
31+
interface Symbol {
32+
readonly [Symbol.toStringTag]: string;
33+
}
34+
declare const console: { log(msg: any): void; };
35+
//// [/home/src/workspaces/project/index.js] *new*
36+
37+
38+
SemanticDiagnostics::
39+
*refresh* /home/src/tslibs/TS/Lib/lib.d.ts
40+
*refresh* /home/src/workspaces/project/index.ts
41+
Signatures::

0 commit comments

Comments
 (0)