diff --git a/src/server/server.ts b/src/server/server.ts index 6e5fc9d68f3..6bb01d64c15 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -214,6 +214,7 @@ namespace ts.server { host: ServerHost, eventPort: number, readonly globalTypingsCacheLocation: string, + readonly typingSafeListLocation: string, private newLine: string) { this.throttledOperations = new ThrottledOperations(host); if (eventPort) { @@ -255,6 +256,9 @@ namespace ts.server { if (this.logger.loggingEnabled() && this.logger.getLogFileName()) { args.push(Arguments.LogFile, combinePaths(getDirectoryPath(normalizeSlashes(this.logger.getLogFileName())), `ti-${process.pid}.log`)); } + if (this.typingSafeListLocation) { + args.push(Arguments.TypingSafeListLocation, this.typingSafeListLocation); + } const execArgv: string[] = []; { for (const arg of process.execArgv) { @@ -361,11 +365,12 @@ namespace ts.server { useSingleInferredProject: boolean, disableAutomaticTypingAcquisition: boolean, globalTypingsCacheLocation: string, + typingSafeListLocation: string, telemetryEnabled: boolean, logger: server.Logger) { const typingsInstaller = disableAutomaticTypingAcquisition ? undefined - : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, host.newLine); + : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, host.newLine); super( host, @@ -695,6 +700,8 @@ namespace ts.server { validateLocaleAndSetLanguage(localeStr, sys); } + const typingSafeListLocation = findArgument("--typingSafeListLocation"); + const useSingleInferredProject = hasArgument("--useSingleInferredProject"); const disableAutomaticTypingAcquisition = hasArgument("--disableAutomaticTypingAcquisition"); const telemetryEnabled = hasArgument(Arguments.EnableTelemetry); @@ -707,6 +714,7 @@ namespace ts.server { useSingleInferredProject, disableAutomaticTypingAcquisition, getGlobalTypingsCacheLocation(), + typingSafeListLocation, telemetryEnabled, logger); process.on("uncaughtException", function (err: Error) { diff --git a/src/server/shared.ts b/src/server/shared.ts index c56d4098e75..1625dcdd4e8 100644 --- a/src/server/shared.ts +++ b/src/server/shared.ts @@ -10,6 +10,7 @@ namespace ts.server { export const GlobalCacheLocation = "--globalTypingsCacheLocation"; export const LogFile = "--logFile"; export const EnableTelemetry = "--enableTelemetry"; + export const TypingSafeListLocation = "--typingSafeListLocation"; } export function hasArgument(argumentName: string) { diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 19f794ad57c..1029fc791e4 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -70,11 +70,11 @@ namespace ts.server.typingsInstaller { private readonly npmPath: string; readonly typesRegistry: Map; - constructor(globalTypingsCacheLocation: string, throttleLimit: number, log: Log) { + constructor(globalTypingsCacheLocation: string, typingSafeListLocation: string, throttleLimit: number, log: Log) { super( sys, globalTypingsCacheLocation, - toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), + typingSafeListLocation ? toPath(typingSafeListLocation, "", createGetCanonicalFileName(sys.useCaseSensitiveFileNames)) : toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), throttleLimit, log); if (this.log.isEnabled()) { @@ -148,6 +148,7 @@ namespace ts.server.typingsInstaller { const logFilePath = findArgument(server.Arguments.LogFile); const globalTypingsCacheLocation = findArgument(server.Arguments.GlobalCacheLocation); + const typingSafeListLocation = findArgument(server.Arguments.TypingSafeListLocation); const log = new FileLog(logFilePath); if (log.isEnabled()) { @@ -161,6 +162,6 @@ namespace ts.server.typingsInstaller { } process.exit(0); }); - const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, /*throttleLimit*/5, log); + const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, /*throttleLimit*/5, log); installer.listen(); } \ No newline at end of file