Call back into getTypeOfFuncClassEnumModule in getTypeOfVariableOrParameterOrProperty if valueDeclaration is irregular kind (#20939)

This commit is contained in:
Wesley Wigham
2018-01-02 17:19:42 -08:00
committed by GitHub
parent 696b0f8d43
commit 29378b2ce2
8 changed files with 67 additions and 39 deletions

View File

@@ -4685,7 +4685,11 @@ namespace ts {
|| isIdentifier(declaration)
|| (isMethodDeclaration(declaration) && !isObjectLiteralMethod(declaration))
|| isMethodSignature(declaration)) {
// TODO: Mimics old behavior from incorrect usage of getWidenedTypeForVariableLikeDeclaration, but seems incorrect
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) {
return getTypeOfFuncClassEnumModule(symbol);
}
type = tryGetTypeFromEffectiveTypeNode(declaration) || anyType;
}
else if (isPropertyAssignment(declaration)) {
@@ -21647,7 +21651,7 @@ namespace ts {
return;
}
const symbol = getSymbolOfNode(node);
const type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol));
const type = convertAutoToAny(getTypeOfSymbol(symbol));
if (node === symbol.valueDeclaration) {
// Node is the primary declaration of the symbol, just validate the initializer
// Don't validate for-in initializer as it is already an error