Skip to content

Commit

Permalink
Instead of passing complete typescript, pass in selected
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Mar 13, 2023
1 parent 075995c commit 8bcf7de
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/compiler/sys.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as ts from "./_namespaces/ts";
import {
AssertionLevel,
closeFileWatcher,
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 12 additions & 2 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as ts from "./_namespaces/ts";
import {
BaseNodeFactory,
CreateSourceFileOptions,
DirectoryWatcherCallback,
EmitHelperFactory,
FileWatcher,
FileWatcherCallback,
FileWatcherEventKind,
GetCanonicalFileName,
MapLike,
ModeAwareCache,
Expand All @@ -19,6 +19,7 @@ import {
Pattern,
ProgramBuildInfo,
SymlinkCache,
System,
ThisContainer,
} from "./_namespaces/ts";

Expand Down Expand Up @@ -7170,7 +7171,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;
Expand Down
6 changes: 5 additions & 1 deletion tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8bcf7de

Please sign in to comment.