mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-09 16:39:46 -05:00
Use value meaning for computed property name for visibility check (#49678)
* Test * Use value meaning for computed property name Fixes #49562
This commit is contained in:
@@ -43363,13 +43363,20 @@ namespace ts {
|
||||
if (!fileToDirective) {
|
||||
return undefined;
|
||||
}
|
||||
// computed property name should use node as value
|
||||
// property access can only be used as values, or types when within an expression with type arguments inside a heritage clause
|
||||
// qualified names can only be used as types\namespaces
|
||||
// identifiers are treated as values only if they appear in type queries
|
||||
let meaning = SymbolFlags.Type | SymbolFlags.Namespace;
|
||||
if ((node.kind === SyntaxKind.Identifier && isInTypeQuery(node)) || (node.kind === SyntaxKind.PropertyAccessExpression && !isInHeritageClause(node))) {
|
||||
let meaning;
|
||||
if (node.parent.kind === SyntaxKind.ComputedPropertyName) {
|
||||
meaning = SymbolFlags.Value | SymbolFlags.ExportValue;
|
||||
}
|
||||
else {
|
||||
meaning = SymbolFlags.Type | SymbolFlags.Namespace;
|
||||
if ((node.kind === SyntaxKind.Identifier && isInTypeQuery(node)) || (node.kind === SyntaxKind.PropertyAccessExpression && !isInHeritageClause(node))) {
|
||||
meaning = SymbolFlags.Value | SymbolFlags.ExportValue;
|
||||
}
|
||||
}
|
||||
|
||||
const symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true);
|
||||
return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [computedPropertyNameAndTypeParameterConflict.ts]
|
||||
declare const O: unique symbol;
|
||||
declare class Bar<O> {
|
||||
[O]: number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [computedPropertyNameAndTypeParameterConflict.js]
|
||||
|
||||
|
||||
//// [computedPropertyNameAndTypeParameterConflict.d.ts]
|
||||
declare const O: unique symbol;
|
||||
declare class Bar<O> {
|
||||
[O]: number;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/compiler/computedPropertyNameAndTypeParameterConflict.ts ===
|
||||
declare const O: unique symbol;
|
||||
>O : Symbol(O, Decl(computedPropertyNameAndTypeParameterConflict.ts, 0, 13))
|
||||
|
||||
declare class Bar<O> {
|
||||
>Bar : Symbol(Bar, Decl(computedPropertyNameAndTypeParameterConflict.ts, 0, 31))
|
||||
>O : Symbol(O, Decl(computedPropertyNameAndTypeParameterConflict.ts, 1, 18))
|
||||
|
||||
[O]: number;
|
||||
>[O] : Symbol(Bar[O], Decl(computedPropertyNameAndTypeParameterConflict.ts, 1, 22))
|
||||
>O : Symbol(O, Decl(computedPropertyNameAndTypeParameterConflict.ts, 0, 13))
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/computedPropertyNameAndTypeParameterConflict.ts ===
|
||||
declare const O: unique symbol;
|
||||
>O : unique symbol
|
||||
|
||||
declare class Bar<O> {
|
||||
>Bar : Bar<O>
|
||||
|
||||
[O]: number;
|
||||
>[O] : number
|
||||
>O : unique symbol
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// @declaration: true
|
||||
declare const O: unique symbol;
|
||||
declare class Bar<O> {
|
||||
[O]: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user