Skip to content

Commit 05cd11c

Browse files
committed
Instead of passing complete typescript, pass in selected
1 parent 9700de6 commit 05cd11c

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

src/compiler/sys.ts

Lines changed: 1 addition & 2 deletions
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

Lines changed: 12 additions & 2 deletions
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

@@ -7206,7 +7207,16 @@ export interface CompilerOptions {
72067207
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
72077208
}
72087209

7209-
export type UserWatchFactoryModule = (mod: { typescript: typeof ts, options: WatchOptions, config: any }) => UserWatchFactory;
7210+
export interface TypeScriptSubsetForWatchFactory {
7211+
sys: System;
7212+
FileWatcherEventKind: typeof FileWatcherEventKind;
7213+
}
7214+
7215+
export type UserWatchFactoryModule = (mod: {
7216+
typescript: TypeScriptSubsetForWatchFactory;
7217+
options: WatchOptions;
7218+
config: any;
7219+
}) => UserWatchFactory;
72107220
export interface UserWatchFactory {
72117221
watchFile?(fileName: string, callback: FileWatcherCallback, pollingInterval: number, options: WatchOptions | undefined): FileWatcher;
72127222
watchDirectory?(fileName: string, callback: DirectoryWatcherCallback, recursive: boolean, options: WatchOptions | undefined): FileWatcher;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7226,8 +7226,12 @@ declare namespace ts {
72267226
useDefineForClassFields?: boolean;
72277227
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
72287228
}
7229+
interface TypeScriptSubsetForWatchFactory {
7230+
sys: System;
7231+
FileWatcherEventKind: typeof FileWatcherEventKind;
7232+
}
72297233
type UserWatchFactoryModule = (mod: {
7230-
typescript: typeof ts;
7234+
typescript: TypeScriptSubsetForWatchFactory;
72317235
options: WatchOptions;
72327236
config: any;
72337237
}) => UserWatchFactory;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3214,8 +3214,12 @@ declare namespace ts {
32143214
useDefineForClassFields?: boolean;
32153215
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
32163216
}
3217+
interface TypeScriptSubsetForWatchFactory {
3218+
sys: System;
3219+
FileWatcherEventKind: typeof FileWatcherEventKind;
3220+
}
32173221
type UserWatchFactoryModule = (mod: {
3218-
typescript: typeof ts;
3222+
typescript: TypeScriptSubsetForWatchFactory;
32193223
options: WatchOptions;
32203224
config: any;
32213225
}) => UserWatchFactory;

0 commit comments

Comments
 (0)