mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
Fix meta property symbol lookup (#48773)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user