mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-23 07:07:09 -05:00
Address PR: use getDefaultLibLocation? insteadof getUserDefinedLibFileName
This commit is contained in:
@@ -629,18 +629,15 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getUserDefinedLibFileName(options: CompilerOptions): string[] {
|
||||
const directoryPath = getDirectoryPath(normalizePath(sys.getExecutingFilePath()));
|
||||
return options.lib.map(fileName => {
|
||||
return combinePaths(directoryPath, fileName);
|
||||
});
|
||||
function getDefaultLibLocation(): string {
|
||||
return getDirectoryPath(normalizePath(sys.getExecutingFilePath()));
|
||||
}
|
||||
|
||||
const newLine = getNewLineCharacter(options);
|
||||
|
||||
return {
|
||||
getSourceFile,
|
||||
getUserDefinedLibFileName,
|
||||
getDefaultLibLocation,
|
||||
getDefaultLibFileName: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), getDefaultLibFileName(options)),
|
||||
writeFile,
|
||||
getCurrentDirectory: memoize(() => sys.getCurrentDirectory()),
|
||||
@@ -767,9 +764,9 @@ namespace ts {
|
||||
processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib*/ true);
|
||||
}
|
||||
else {
|
||||
const libFileNames = host.getUserDefinedLibFileName(options);
|
||||
libFileNames.forEach(libFileName => {
|
||||
processRootFile(libFileName, /*isDefaultLib*/ true);
|
||||
const libDirectory = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(host.getDefaultLibFileName(options));
|
||||
forEach(options.lib, libFileName => {
|
||||
processRootFile(combinePaths(libDirectory, libFileName), /*isDefaultLib*/ true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2752,7 +2752,7 @@ namespace ts {
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getUserDefinedLibFileName(options: CompilerOptions): string[];
|
||||
getDefaultLibLocation?(): string;
|
||||
writeFile: WriteFileCallback;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
|
||||
@@ -887,7 +887,6 @@ namespace Harness {
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getSourceFile,
|
||||
getDefaultLibFileName: options => options.target === ts.ScriptTarget.ES6 ? es2015DefaultLibFileName : defaultLibFileName,
|
||||
getUserDefinedLibFileName: options => options.lib,
|
||||
writeFile,
|
||||
getCanonicalFileName,
|
||||
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
|
||||
|
||||
@@ -172,7 +172,6 @@ class ProjectRunner extends RunnerBase {
|
||||
return {
|
||||
getSourceFile,
|
||||
getDefaultLibFileName: options => Harness.Compiler.defaultLibFileName,
|
||||
getUserDefinedLibFileName: options => [],
|
||||
writeFile,
|
||||
getCurrentDirectory,
|
||||
getCanonicalFileName: Harness.Compiler.getCanonicalFileName,
|
||||
|
||||
@@ -1926,7 +1926,6 @@ namespace ts {
|
||||
}
|
||||
},
|
||||
getDefaultLibFileName: () => "lib.d.ts",
|
||||
getUserDefinedLibFileName: () => [],
|
||||
useCaseSensitiveFileNames: () => false,
|
||||
getCanonicalFileName: fileName => fileName,
|
||||
getCurrentDirectory: () => "",
|
||||
@@ -2826,7 +2825,6 @@ namespace ts {
|
||||
getCanonicalFileName,
|
||||
useCaseSensitiveFileNames: () => useCaseSensitivefileNames,
|
||||
getNewLine: () => getNewLineOrDefaultFromHost(host),
|
||||
getUserDefinedLibFileName: (options) => [],
|
||||
getDefaultLibFileName: (options) => host.getDefaultLibFileName(options),
|
||||
writeFile: (fileName, data, writeByteOrderMark) => { },
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
|
||||
@@ -281,7 +281,6 @@ module ts {
|
||||
return hasProperty(files, path) ? createSourceFile(fileName, files[path], languageVersion) : undefined;
|
||||
},
|
||||
getDefaultLibFileName: () => "lib.d.ts",
|
||||
getUserDefinedLibFileName: options => [],
|
||||
writeFile: (fileName, content): void => { throw new Error("NotImplemented"); },
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getCanonicalFileName: fileName => fileName.toLowerCase(),
|
||||
@@ -365,7 +364,6 @@ export = C;
|
||||
return hasProperty(files, path) ? createSourceFile(fileName, files[path], languageVersion) : undefined;
|
||||
},
|
||||
getDefaultLibFileName: () => "lib.d.ts",
|
||||
getUserDefinedLibFileName: options => [],
|
||||
writeFile: (fileName, content): void => { throw new Error("NotImplemented"); },
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getCanonicalFileName,
|
||||
|
||||
@@ -111,7 +111,6 @@ module ts {
|
||||
getDefaultLibFileName(): string {
|
||||
return "lib.d.ts"
|
||||
},
|
||||
getUserDefinedLibFileName: options => [],
|
||||
writeFile(file, text) {
|
||||
throw new Error("NYI");
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user