Variables from different source files default to their declared type
This commit is contained in:
parent
d28a4feeba
commit
d735b7acbf
2 changed files with 10 additions and 1 deletions
|
@ -7936,7 +7936,7 @@ namespace ts {
|
|||
const declaration = localOrExportSymbol.valueDeclaration;
|
||||
const defaultsToDeclaredType = !strictNullChecks || !declaration ||
|
||||
declaration.kind === SyntaxKind.Parameter || isInAmbientContext(declaration) ||
|
||||
getContainingFunction(declaration) !== getContainingFunction(node);
|
||||
getContainingFunctionOrSourceFile(declaration) !== getContainingFunctionOrSourceFile(node);
|
||||
if (defaultsToDeclaredType && !(type.flags & TypeFlags.Narrowable)) {
|
||||
return type;
|
||||
}
|
||||
|
|
|
@ -840,6 +840,15 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
export function getContainingFunctionOrSourceFile(node: Node): FunctionLikeDeclaration | SourceFile {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (isFunctionLike(node) || node.kind === SyntaxKind.SourceFile) {
|
||||
return <FunctionLikeDeclaration | SourceFile>node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getContainingClass(node: Node): ClassLikeDeclaration {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
|
|
Loading…
Reference in a new issue