diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 0e302e6440266..887d33ebf38b7 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1,4 +1,3 @@ -import * as ts from "./_namespaces/ts"; import { AssertionLevel, closeFileWatcher, @@ -1016,7 +1015,7 @@ export function createSystemWatchFunctions({ sysLog ); if (typeof resolvedModule === "function") { - return setUserWatchFactory(options, resolvedModule({ typescript: ts, options, config: pluginConfigEntry })); + return setUserWatchFactory(options, resolvedModule({ typescript: { sys, FileWatcherEventKind }, options, config: pluginConfigEntry })); } else if (!resolvedModule) { forEach(errorLogs, sysLog); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2031270ce8440..30681c3a006ec 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1,4 +1,3 @@ -import * as ts from "./_namespaces/ts"; import { BaseNodeFactory, CreateSourceFileOptions, @@ -6,6 +5,7 @@ import { EmitHelperFactory, FileWatcher, FileWatcherCallback, + FileWatcherEventKind, GetCanonicalFileName, MapLike, ModeAwareCache, @@ -19,6 +19,7 @@ import { Pattern, ProgramBuildInfo, SymlinkCache, + System, ThisContainer, } from "./_namespaces/ts"; @@ -7189,7 +7190,16 @@ export interface CompilerOptions { [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } -export type UserWatchFactoryModule = (mod: { typescript: typeof ts, options: WatchOptions, config: any }) => UserWatchFactory; +export interface TypeScriptSubsetForWatchFactory { + sys: System; + FileWatcherEventKind: typeof FileWatcherEventKind; +} + +export type UserWatchFactoryModule = (mod: { + typescript: TypeScriptSubsetForWatchFactory; + options: WatchOptions; + config: any; +}) => UserWatchFactory; export interface UserWatchFactory { watchFile?(fileName: string, callback: FileWatcherCallback, pollingInterval: number, options: WatchOptions | undefined): FileWatcher; watchDirectory?(fileName: string, callback: DirectoryWatcherCallback, recursive: boolean, options: WatchOptions | undefined): FileWatcher; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index e03815891849a..b1791fd69b926 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -7157,8 +7157,12 @@ declare namespace ts { useDefineForClassFields?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } + interface TypeScriptSubsetForWatchFactory { + sys: System; + FileWatcherEventKind: typeof FileWatcherEventKind; + } type UserWatchFactoryModule = (mod: { - typescript: typeof ts; + typescript: TypeScriptSubsetForWatchFactory; options: WatchOptions; config: any; }) => UserWatchFactory; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 1539451fae2e6..8e4971937e762 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3213,8 +3213,12 @@ declare namespace ts { useDefineForClassFields?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } + interface TypeScriptSubsetForWatchFactory { + sys: System; + FileWatcherEventKind: typeof FileWatcherEventKind; + } type UserWatchFactoryModule = (mod: { - typescript: typeof ts; + typescript: TypeScriptSubsetForWatchFactory; options: WatchOptions; config: any; }) => UserWatchFactory;