mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
parent
3704ad74d1
commit
f0a996e6fb
@ -44,15 +44,6 @@ namespace ts {
|
||||
return compilerOptions.traceModuleResolution && host.trace !== undefined;
|
||||
}
|
||||
|
||||
function startsWith(str: string, prefix: string): boolean {
|
||||
return str.lastIndexOf(prefix, 0) === 0;
|
||||
}
|
||||
|
||||
function endsWith(str: string, suffix: string): boolean {
|
||||
const expectedPos = str.length - suffix.length;
|
||||
return str.indexOf(suffix, expectedPos) === expectedPos;
|
||||
}
|
||||
|
||||
function hasZeroOrOneAsteriskCharacter(str: string): boolean {
|
||||
let seenAsterisk = false;
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
|
||||
@ -2927,4 +2927,13 @@ namespace ts {
|
||||
export function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean {
|
||||
return node.flags & NodeFlags.AccessibilityModifier && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
|
||||
}
|
||||
|
||||
export function startsWith(str: string, prefix: string): boolean {
|
||||
return str.lastIndexOf(prefix, 0) === 0;
|
||||
}
|
||||
|
||||
export function endsWith(str: string, suffix: string): boolean {
|
||||
const expectedPos = str.length - suffix.length;
|
||||
return str.indexOf(suffix, expectedPos) === expectedPos;
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ namespace FourSlash {
|
||||
|
||||
function tryAdd(path: string) {
|
||||
const inputFile = inputFiles[path];
|
||||
if (inputFile && !Harness.isLibraryFile(path)) {
|
||||
if (inputFile && !Harness.isDefaultLibraryFile(path)) {
|
||||
languageServiceAdapterHost.addScript(path, inputFile);
|
||||
return true;
|
||||
}
|
||||
@ -298,7 +298,7 @@ namespace FourSlash {
|
||||
else {
|
||||
// resolveReference file-option is not specified then do not resolve any files and include all inputFiles
|
||||
ts.forEachKey(this.inputFiles, fileName => {
|
||||
if (!Harness.isLibraryFile(fileName)) {
|
||||
if (!Harness.isDefaultLibraryFile(fileName)) {
|
||||
this.languageServiceAdapterHost.addScript(fileName, this.inputFiles[fileName]);
|
||||
}
|
||||
});
|
||||
|
||||
@ -816,8 +816,7 @@ namespace Harness {
|
||||
};
|
||||
|
||||
export function getDefaultLibrarySourceFile(fileName = defaultLibFileName): ts.SourceFile {
|
||||
if (!isLibraryFile(fileName)) {
|
||||
assert(!isLibraryFile(fileName), "Expected library fileName");
|
||||
if (!isDefaultLibraryFile(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -1157,7 +1156,7 @@ namespace Harness {
|
||||
// then they will be added twice thus triggering 'total errors' assertion with condition
|
||||
// 'totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length
|
||||
|
||||
if (!error.file || !isLibraryFile(error.file.fileName)) {
|
||||
if (!error.file || !isDefaultLibraryFile(error.file.fileName)) {
|
||||
totalErrorsReportedInNonLibraryFiles++;
|
||||
}
|
||||
}
|
||||
@ -1236,7 +1235,7 @@ namespace Harness {
|
||||
});
|
||||
|
||||
const numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
return diagnostic.file && (isLibraryFile(diagnostic.file.fileName) || isBuiltFile(diagnostic.file.fileName));
|
||||
return diagnostic.file && (isDefaultLibraryFile(diagnostic.file.fileName) || isBuiltFile(diagnostic.file.fileName));
|
||||
});
|
||||
|
||||
const numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
@ -1623,10 +1622,10 @@ namespace Harness {
|
||||
}
|
||||
}
|
||||
|
||||
// Regex for check if the give filePath is a library file
|
||||
const libRegex = /lib(\.\S+)*\.d\.ts/;
|
||||
export function isLibraryFile(filePath: string): boolean {
|
||||
return !!libRegex.exec(Path.getFileName(filePath));
|
||||
export function isDefaultLibraryFile(filePath: string): boolean {
|
||||
// We need to make sure that the filePath is prefixed with "lib." not just containing "lib." and end with ".d.ts"
|
||||
const fileName = Path.getFileName(filePath);
|
||||
return ts.startsWith(fileName, "lib.") && ts.endsWith(fileName, ".d.ts");
|
||||
}
|
||||
|
||||
export function isBuiltFile(filePath: string): boolean {
|
||||
|
||||
@ -412,7 +412,7 @@ class ProjectRunner extends RunnerBase {
|
||||
|
||||
function getErrorsBaseline(compilerResult: CompileProjectFilesResult) {
|
||||
const inputFiles = compilerResult.program ? ts.map(ts.filter(compilerResult.program.getSourceFiles(),
|
||||
sourceFile => !Harness.isLibraryFile(sourceFile.fileName)),
|
||||
sourceFile => !Harness.isDefaultLibraryFile(sourceFile.fileName)),
|
||||
sourceFile => {
|
||||
return {
|
||||
unitName: ts.isRootedDiskPath(sourceFile.fileName) ?
|
||||
|
||||
@ -95,13 +95,13 @@ namespace RWC {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Harness.isLibraryFile(fileRead.path)) {
|
||||
if (!Harness.isDefaultLibraryFile(fileRead.path)) {
|
||||
if (inInputList) {
|
||||
continue;
|
||||
}
|
||||
otherFiles.push(getHarnessCompilerInputUnit(fileRead.path));
|
||||
}
|
||||
else if (!opts.options.noLib && Harness.isLibraryFile(fileRead.path)) {
|
||||
else if (!opts.options.noLib && Harness.isDefaultLibraryFile(fileRead.path)) {
|
||||
if (!inInputList) {
|
||||
// If useCustomLibraryFile is true, we will use lib.d.ts from json object
|
||||
// otherwise use the lib.d.ts from built/local
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user