Skip to content
This repository was archived by the owner on Dec 1, 2019. It is now read-only.

Commit 50df5f5

Browse files
committed
refactor: extract some types
1 parent c82882d commit 50df5f5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/checker/runtime.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ interface File {
7171
text: string
7272
}
7373

74+
type WatchCallbacks<T> = Map<string, T[]>
75+
type WatchHost = ts.WatchCompilerHostOfFilesAndCompilerOptions<
76+
ts.SemanticDiagnosticsBuilderProgram
77+
> &
78+
ts.BuilderProgramHost
79+
7480
type Filter = (file: ts.SourceFile) => boolean
7581

7682
function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Res) => void) {
@@ -85,7 +91,6 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re
8591
let rootFilesChanged = false
8692

8793
let filesRegex: RegExp
88-
type WatchCallbacks<T> = Map<string, T[]>
8994
const watchedFiles: WatchCallbacks<ts.FileWatcherCallback> = new Map()
9095
const watchedDirectories: WatchCallbacks<ts.DirectoryWatcherCallback> = new Map()
9196
const watchedDirectoriesRecursive: WatchCallbacks<ts.DirectoryWatcherCallback> = new Map()
@@ -94,17 +99,12 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re
9499
? fileName => fileName.toLowerCase()
95100
: fileName => fileName
96101

97-
let watchHost: ts.WatchCompilerHostOfFilesAndCompilerOptions<
98-
ts.SemanticDiagnosticsBuilderProgram
99-
>
102+
let watchHost: WatchHost
100103
let watch: ts.WatchOfFilesAndCompilerOptions<ts.SemanticDiagnosticsBuilderProgram>
101104

102105
let finalTransformers: undefined | (() => ts.CustomTransformers)
103106

104-
function createWatchHost(): ts.WatchCompilerHostOfFilesAndCompilerOptions<
105-
ts.SemanticDiagnosticsBuilderProgram
106-
> &
107-
ts.BuilderProgramHost {
107+
function createWatchHost(): WatchHost {
108108
return {
109109
rootFiles: getRootFiles(),
110110
options: compilerOptions,
@@ -163,6 +163,7 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re
163163
compiler.getDefaultLibFileName(options)
164164
)
165165
}
166+
166167
function invokeWatcherCallbacks(
167168
callbacks: ts.FileWatcherCallback[] | undefined,
168169
fileName: string,

0 commit comments

Comments
 (0)