mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-22 16:24:12 -06:00
Changed check for default library by first checking hasNoDefaultLib, second library path and third name of file.
This commit is contained in:
parent
675b6fb90c
commit
88262dbeb0
@ -436,6 +436,7 @@ namespace ts {
|
||||
host = host || createCompilerHost(options);
|
||||
|
||||
let skipDefaultLib = options.noLib;
|
||||
const defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(host.getDefaultLibFileName(options));
|
||||
const programDiagnostics = createDiagnosticCollection();
|
||||
const currentDirectory = host.getCurrentDirectory();
|
||||
const supportedExtensions = getSupportedExtensions(options);
|
||||
@ -977,7 +978,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isSourceFileDefaultLibrary(file: SourceFile): boolean {
|
||||
return file.fileName === host.getDefaultLibFileName(options);
|
||||
if (file.hasNoDefaultLib) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (defaultLibraryPath !== undefined && defaultLibraryPath.length !== 0) {
|
||||
return comparePaths(defaultLibraryPath, file.path, currentDirectory, /*ignoreCase*/ true) === Comparison.EqualTo;
|
||||
}
|
||||
|
||||
return compareStrings(file.fileName, host.getDefaultLibFileName(options), /*ignoreCase*/ true) === Comparison.EqualTo;
|
||||
}
|
||||
|
||||
function getDiagnosticsProducingTypeChecker() {
|
||||
@ -1209,7 +1218,7 @@ namespace ts {
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics._0_can_only_be_used_in_a_ts_file, "?"));
|
||||
return;
|
||||
}
|
||||
// falls through
|
||||
// falls through
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
@ -1291,7 +1300,7 @@ namespace ts {
|
||||
diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file));
|
||||
return;
|
||||
}
|
||||
// falls through
|
||||
// falls through
|
||||
case SyntaxKind.VariableStatement:
|
||||
// Check modifiers
|
||||
if (nodes === (<ClassDeclaration | FunctionLikeDeclaration | VariableStatement>parent).modifiers) {
|
||||
@ -1339,8 +1348,8 @@ namespace ts {
|
||||
if (isConstValid) {
|
||||
continue;
|
||||
}
|
||||
// to report error,
|
||||
// falls through
|
||||
// to report error,
|
||||
// falls through
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
@ -1556,10 +1565,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getSourceFileFromReferenceWorker(
|
||||
fileName: string,
|
||||
getSourceFile: (fileName: string) => SourceFile | undefined,
|
||||
fail?: (diagnostic: DiagnosticMessage, ...argument: string[]) => void,
|
||||
refFile?: SourceFile): SourceFile | undefined {
|
||||
fileName: string,
|
||||
getSourceFile: (fileName: string) => SourceFile | undefined,
|
||||
fail?: (diagnostic: DiagnosticMessage, ...argument: string[]) => void,
|
||||
refFile?: SourceFile): SourceFile | undefined {
|
||||
|
||||
if (hasExtension(fileName)) {
|
||||
if (!options.allowNonTsExtensions && !forEach(supportedExtensions, extension => fileExtensionIs(host.getCanonicalFileName(fileName), extension))) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user