Skip to content

Commit 711f62f

Browse files
authored
Merge pull request #14807 from minestarks/typingsafelist
Allow specifying the location of typingSafeList.json
2 parents 0fd0903 + f1339ec commit 711f62f

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/server/server.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ namespace ts.server {
219219
host: ServerHost,
220220
eventPort: number,
221221
readonly globalTypingsCacheLocation: string,
222+
readonly typingSafeListLocation: string,
222223
private newLine: string) {
223224
this.throttledOperations = new ThrottledOperations(host);
224225
if (eventPort) {
@@ -260,6 +261,9 @@ namespace ts.server {
260261
if (this.logger.loggingEnabled() && this.logger.getLogFileName()) {
261262
args.push(Arguments.LogFile, combinePaths(getDirectoryPath(normalizeSlashes(this.logger.getLogFileName())), `ti-${process.pid}.log`));
262263
}
264+
if (this.typingSafeListLocation) {
265+
args.push(Arguments.TypingSafeListLocation, this.typingSafeListLocation);
266+
}
263267
const execArgv: string[] = [];
264268
{
265269
for (const arg of process.execArgv) {
@@ -378,11 +382,12 @@ namespace ts.server {
378382
useSingleInferredProject: boolean,
379383
disableAutomaticTypingAcquisition: boolean,
380384
globalTypingsCacheLocation: string,
385+
typingSafeListLocation: string,
381386
telemetryEnabled: boolean,
382387
logger: server.Logger) {
383388
const typingsInstaller = disableAutomaticTypingAcquisition
384389
? undefined
385-
: new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, host.newLine);
390+
: new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, host.newLine);
386391

387392
super(
388393
host,
@@ -729,6 +734,8 @@ namespace ts.server {
729734
validateLocaleAndSetLanguage(localeStr, sys);
730735
}
731736

737+
const typingSafeListLocation = findArgument("--typingSafeListLocation");
738+
732739
const useSingleInferredProject = hasArgument("--useSingleInferredProject");
733740
const disableAutomaticTypingAcquisition = hasArgument("--disableAutomaticTypingAcquisition");
734741
const telemetryEnabled = hasArgument(Arguments.EnableTelemetry);
@@ -741,6 +748,7 @@ namespace ts.server {
741748
useSingleInferredProject,
742749
disableAutomaticTypingAcquisition,
743750
getGlobalTypingsCacheLocation(),
751+
typingSafeListLocation,
744752
telemetryEnabled,
745753
logger);
746754
process.on("uncaughtException", function (err: Error) {

src/server/shared.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace ts.server {
1111
export const GlobalCacheLocation = "--globalTypingsCacheLocation";
1212
export const LogFile = "--logFile";
1313
export const EnableTelemetry = "--enableTelemetry";
14+
export const TypingSafeListLocation = "--typingSafeListLocation";
1415
}
1516

1617
export function hasArgument(argumentName: string) {

src/server/typingsInstaller/nodeTypingsInstaller.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ namespace ts.server.typingsInstaller {
7676

7777
private delayedInitializationError: InitializationFailedResponse;
7878

79-
constructor(globalTypingsCacheLocation: string, throttleLimit: number, log: Log) {
79+
constructor(globalTypingsCacheLocation: string, typingSafeListLocation: string, throttleLimit: number, log: Log) {
8080
super(
8181
sys,
8282
globalTypingsCacheLocation,
83-
toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
83+
typingSafeListLocation ? toPath(typingSafeListLocation, "", createGetCanonicalFileName(sys.useCaseSensitiveFileNames)) : toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
8484
throttleLimit,
8585
log);
8686
if (this.log.isEnabled()) {
@@ -164,6 +164,7 @@ namespace ts.server.typingsInstaller {
164164

165165
const logFilePath = findArgument(server.Arguments.LogFile);
166166
const globalTypingsCacheLocation = findArgument(server.Arguments.GlobalCacheLocation);
167+
const typingSafeListLocation = findArgument(server.Arguments.TypingSafeListLocation);
167168

168169
const log = new FileLog(logFilePath);
169170
if (log.isEnabled()) {
@@ -177,6 +178,6 @@ namespace ts.server.typingsInstaller {
177178
}
178179
process.exit(0);
179180
});
180-
const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, /*throttleLimit*/5, log);
181+
const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, /*throttleLimit*/5, log);
181182
installer.listen();
182183
}

0 commit comments

Comments
 (0)