Skip to content

Commit 18bf8ce

Browse files
committed
Instead of passing complete typescript, pass in selected
1 parent 3b6b4a9 commit 18bf8ce

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

src/compiler/sys.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as ts from "./_namespaces/ts";
21
import {
32
AssertionLevel,
43
closeFileWatcher,
@@ -1016,7 +1015,7 @@ export function createSystemWatchFunctions({
10161015
sysLog
10171016
);
10181017
if (typeof resolvedModule === "function") {
1019-
return setUserWatchFactory(options, resolvedModule({ typescript: ts, options, config: pluginConfigEntry }));
1018+
return setUserWatchFactory(options, resolvedModule({ typescript: { sys, FileWatcherEventKind }, options, config: pluginConfigEntry }));
10201019
}
10211020
else if (!resolvedModule) {
10221021
forEach(errorLogs, sysLog);

src/compiler/types.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import * as ts from "./_namespaces/ts";
21
import {
32
BaseNodeFactory,
43
CreateSourceFileOptions,
54
DirectoryWatcherCallback,
65
EmitHelperFactory,
76
FileWatcher,
87
FileWatcherCallback,
8+
FileWatcherEventKind,
99
GetCanonicalFileName,
1010
MapLike,
1111
ModeAwareCache,
@@ -19,6 +19,7 @@ import {
1919
Pattern,
2020
ProgramBuildInfo,
2121
SymlinkCache,
22+
System,
2223
ThisContainer,
2324
} from "./_namespaces/ts";
2425

@@ -7170,7 +7171,16 @@ export interface CompilerOptions {
71707171
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
71717172
}
71727173

7173-
export type UserWatchFactoryModule = (mod: { typescript: typeof ts, options: WatchOptions, config: any }) => UserWatchFactory;
7174+
export interface TypeScriptSubsetForWatchFactory {
7175+
sys: System;
7176+
FileWatcherEventKind: typeof FileWatcherEventKind;
7177+
}
7178+
7179+
export type UserWatchFactoryModule = (mod: {
7180+
typescript: TypeScriptSubsetForWatchFactory;
7181+
options: WatchOptions;
7182+
config: any;
7183+
}) => UserWatchFactory;
71747184
export interface UserWatchFactory {
71757185
watchFile?(fileName: string, callback: FileWatcherCallback, pollingInterval: number, options: WatchOptions | undefined): FileWatcher;
71767186
watchDirectory?(fileName: string, callback: DirectoryWatcherCallback, recursive: boolean, options: WatchOptions | undefined): FileWatcher;

tests/baselines/reference/api/tsserverlibrary.d.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -7157,8 +7157,12 @@ declare namespace ts {
71577157
useDefineForClassFields?: boolean;
71587158
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
71597159
}
7160+
interface TypeScriptSubsetForWatchFactory {
7161+
sys: System;
7162+
FileWatcherEventKind: typeof FileWatcherEventKind;
7163+
}
71607164
type UserWatchFactoryModule = (mod: {
7161-
typescript: typeof ts;
7165+
typescript: TypeScriptSubsetForWatchFactory;
71627166
options: WatchOptions;
71637167
config: any;
71647168
}) => UserWatchFactory;

tests/baselines/reference/api/typescript.d.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -3213,8 +3213,12 @@ declare namespace ts {
32133213
useDefineForClassFields?: boolean;
32143214
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
32153215
}
3216+
interface TypeScriptSubsetForWatchFactory {
3217+
sys: System;
3218+
FileWatcherEventKind: typeof FileWatcherEventKind;
3219+
}
32163220
type UserWatchFactoryModule = (mod: {
3217-
typescript: typeof ts;
3221+
typescript: TypeScriptSubsetForWatchFactory;
32183222
options: WatchOptions;
32193223
config: any;
32203224
}) => UserWatchFactory;

0 commit comments

Comments
 (0)