In getSuggestionForNonexistentSymbol, guard name against undefined

This commit is contained in:
Nathan Shively-Sanders
2017-10-09 10:45:50 -07:00
parent 8a55baf9a3
commit 405d8cf8eb
+4 -1
View File
@@ -15064,7 +15064,10 @@ namespace ts {
function getSuggestionForNonexistentSymbol(location: Node, name: __String, meaning: SymbolFlags): string {
const result = resolveNameHelper(location, name, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ false, (symbols, name, meaning) => {
// `name` from the callback === the outer `name`
// NOTE: `name` from the callback is supposed to === the outer `name`, but is undefined in some cases
if (name === undefined) {
return undefined;
}
const symbol = getSymbol(symbols, name, meaning);
// Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function
// So the table *contains* `x` but `x` isn't actually in scope.