mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 10:46:28 -05:00
Merge pull request #19039 from Microsoft/guard-name-in-getSuggestionForNonexistentSymbol
In getSuggestionForNonexistentSymbol, guard name against undefined
This commit is contained in:
@@ -15344,9 +15344,10 @@ namespace ts {
|
||||
return suggestion && symbolName(suggestion);
|
||||
}
|
||||
|
||||
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`
|
||||
function getSuggestionForNonexistentSymbol(location: Node, outerName: __String, meaning: SymbolFlags): string {
|
||||
Debug.assert(outerName !== undefined, "outername should always be defined");
|
||||
const result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, (symbols, name, meaning) => {
|
||||
Debug.assertEqual(outerName, name, "name should equal outerName");
|
||||
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.
|
||||
|
||||
@@ -22,7 +22,9 @@ namespace ts.codefix {
|
||||
}
|
||||
else {
|
||||
const meaning = getMeaningFromLocation(node);
|
||||
suggestion = checker.getSuggestionForNonexistentSymbol(node, getTextOfNode(node), convertSemanticMeaningToSymbolFlags(meaning));
|
||||
const name = getTextOfNode(node);
|
||||
Debug.assert(name !== undefined, "name should be defined");
|
||||
suggestion = checker.getSuggestionForNonexistentSymbol(node, name, convertSemanticMeaningToSymbolFlags(meaning));
|
||||
}
|
||||
if (suggestion) {
|
||||
return [{
|
||||
|
||||
Reference in New Issue
Block a user