Fix meta property symbol lookup (#48773)

This commit is contained in:
Wesley Wigham
2022-04-19 17:57:06 -07:00
committed by GitHub
parent d81a976c14
commit ce487e4fd3
19 changed files with 100 additions and 9 deletions

View File

@@ -41982,15 +41982,20 @@ namespace ts {
return propertyDeclaration;
}
}
else if (isMetaProperty(parent)) {
const parentType = getTypeOfNode(parent);
const propertyDeclaration = getPropertyOfType(parentType, (node as Identifier).escapedText);
if (propertyDeclaration) {
return propertyDeclaration;
}
if (parent.keywordToken === SyntaxKind.NewKeyword) {
else if (isMetaProperty(parent) && parent.name === node) {
if (parent.keywordToken === SyntaxKind.NewKeyword && idText(node as Identifier) === "target") {
// `target` in `new.target`
return checkNewTargetMetaProperty(parent).symbol;
}
// The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but
// we have a fake expression type made for other reasons already, whose transient `meta`
// member should more exactly be the kind of (declarationless) symbol we want.
// (See #44364 and #45031 for relevant implementation PRs)
if (parent.keywordToken === SyntaxKind.ImportKeyword && idText(node as Identifier) === "meta") {
return getGlobalImportMetaExpressionType().members!.get("meta" as __String);
}
// no other meta properties are valid syntax, thus no others should have symbols
return undefined;
}
}