Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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))
}


Original file line number Diff line number Diff line change
@@ -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
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @declaration: true
declare const O: unique symbol;
declare class Bar<O> {
[O]: number;
}