mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Merge pull request #23878 from Microsoft/vfsBaselines
New vfs baselines follow-up
This commit is contained in:
@@ -289,27 +289,7 @@ namespace fakes {
|
||||
}
|
||||
|
||||
public getDefaultLibFileName(options: ts.CompilerOptions): string {
|
||||
// return vpath.resolve(this.getDefaultLibLocation(), ts.getDefaultLibFileName(options));
|
||||
|
||||
// TODO(rbuckton): This patches the baseline to replace lib.es5.d.ts with lib.d.ts.
|
||||
// This is only to make the PR for this change easier to read. A follow-up PR will
|
||||
// revert this change and accept the new baselines.
|
||||
// See https://github.com/Microsoft/TypeScript/pull/20763#issuecomment-352553264
|
||||
return vpath.resolve(this.getDefaultLibLocation(), getDefaultLibFileName(options));
|
||||
function getDefaultLibFileName(options: ts.CompilerOptions) {
|
||||
switch (options.target) {
|
||||
case ts.ScriptTarget.ESNext:
|
||||
case ts.ScriptTarget.ES2017:
|
||||
return "lib.es2017.d.ts";
|
||||
case ts.ScriptTarget.ES2016:
|
||||
return "lib.es2016.d.ts";
|
||||
case ts.ScriptTarget.ES2015:
|
||||
return "lib.es2015.d.ts";
|
||||
|
||||
default:
|
||||
return "lib.d.ts";
|
||||
}
|
||||
}
|
||||
return vpath.resolve(this.getDefaultLibLocation(), ts.getDefaultLibFileName(options));
|
||||
}
|
||||
|
||||
public getSourceFile(fileName: string, languageVersion: number): ts.SourceFile | undefined {
|
||||
|
||||
@@ -219,13 +219,7 @@ namespace project {
|
||||
.map(output => utils.removeTestPathPrefixes(vpath.isAbsolute(output) ? vpath.relative(cwd, output, ignoreCase) : output));
|
||||
|
||||
const content = JSON.stringify(resolutionInfo, undefined, " ");
|
||||
|
||||
// TODO(rbuckton): This patches the baseline to replace lib.es5.d.ts with lib.d.ts.
|
||||
// This is only to make the PR for this change easier to read. A follow-up PR will
|
||||
// revert this change and accept the new baselines.
|
||||
// See https://github.com/Microsoft/TypeScript/pull/20763#issuecomment-352553264
|
||||
const patchedContent = content.replace(/lib\.es5\.d\.ts/g, "lib.d.ts");
|
||||
Harness.Baseline.runBaseline(this.getBaselineFolder(this.compilerResult.moduleKind) + this.testCaseJustName + ".json", () => patchedContent);
|
||||
Harness.Baseline.runBaseline(this.getBaselineFolder(this.compilerResult.moduleKind) + this.testCaseJustName + ".json", () => content);
|
||||
}
|
||||
|
||||
public verifyDiagnostics() {
|
||||
|
||||
@@ -1253,25 +1253,6 @@ namespace vfs {
|
||||
node: Inode | undefined;
|
||||
}
|
||||
|
||||
// TODO(rbuckton): This patches the baseline to replace lib.d.ts with lib.es5.d.ts.
|
||||
// This is only to make the PR for this change easier to read. A follow-up PR will
|
||||
// revert this change and accept the new baselines.
|
||||
// See https://github.com/Microsoft/TypeScript/pull/20763#issuecomment-352553264
|
||||
function patchResolver(host: FileSystemResolverHost, resolver: FileSystemResolver): FileSystemResolver {
|
||||
const libFile = vpath.combine(host.getWorkspaceRoot(), "built/local/lib.d.ts");
|
||||
const es5File = vpath.combine(host.getWorkspaceRoot(), "built/local/lib.es5.d.ts");
|
||||
const stringComparer = host.useCaseSensitiveFileNames() ? vpath.compareCaseSensitive : vpath.compareCaseInsensitive;
|
||||
return {
|
||||
readdirSync: path => resolver.readdirSync(path),
|
||||
statSync: path => resolver.statSync(fixPath(path)),
|
||||
readFileSync: (path) => resolver.readFileSync(fixPath(path))
|
||||
};
|
||||
|
||||
function fixPath(path: string) {
|
||||
return stringComparer(path, libFile) === 0 ? es5File : path;
|
||||
}
|
||||
}
|
||||
|
||||
let builtLocalHost: FileSystemResolverHost | undefined;
|
||||
let builtLocalCI: FileSystem | undefined;
|
||||
let builtLocalCS: FileSystem | undefined;
|
||||
@@ -1286,7 +1267,7 @@ namespace vfs {
|
||||
const resolver = createResolver(host);
|
||||
builtLocalCI = new FileSystem(/*ignoreCase*/ true, {
|
||||
files: {
|
||||
[builtFolder]: new Mount(vpath.resolve(host.getWorkspaceRoot(), "built/local"), patchResolver(host, resolver)),
|
||||
[builtFolder]: new Mount(vpath.resolve(host.getWorkspaceRoot(), "built/local"), resolver),
|
||||
[testLibFolder]: new Mount(vpath.resolve(host.getWorkspaceRoot(), "tests/lib"), resolver),
|
||||
[srcFolder]: {}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user