Skip to content

Commit a299d2d

Browse files
author
Andy
authored
isDeclarationName: support ComputedPropertyName (#22123)
* isDeclarationName: support ComputedPropertyName * update additional baseline
1 parent 75fa945 commit a299d2d

File tree

887 files changed

+2503
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

887 files changed

+2503
-50
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23094,7 +23094,7 @@ namespace ts {
2309423094
const rootChain = () => chainDiagnosticMessages(
2309523095
/*details*/ undefined,
2309623096
Diagnostics.Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2,
23097-
unescapeLeadingUnderscores(declaredProp.escapedName),
23097+
symbolToString(declaredProp),
2309823098
typeToString(typeWithThis),
2309923099
typeToString(baseWithThis)
2310023100
);

src/compiler/utilities.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,16 +1860,9 @@ namespace ts {
18601860
return false;
18611861
}
18621862

1863-
// True if the given identifier, string literal, or number literal is the name of a declaration node
1863+
// True if `name` is the name of a declaration node
18641864
export function isDeclarationName(name: Node): boolean {
1865-
switch (name.kind) {
1866-
case SyntaxKind.Identifier:
1867-
case SyntaxKind.StringLiteral:
1868-
case SyntaxKind.NumericLiteral:
1869-
return isDeclaration(name.parent) && name.parent.name === name;
1870-
default:
1871-
return false;
1872-
}
1865+
return !isSourceFile(name) && !isBindingPattern(name) && isDeclaration(name.parent) && name.parent.name === name;
18731866
}
18741867

18751868
// See GH#16030

src/harness/harness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ namespace Harness {
15321532
}
15331533

15341534
if (typesError && symbolsError) {
1535-
throw new Error(typesError.message + Harness.IO.newLine() + symbolsError.message);
1535+
throw new Error(typesError.stack + Harness.IO.newLine() + symbolsError.stack);
15361536
}
15371537

15381538
if (typesError) {

tests/baselines/reference/ES5For-ofTypeCheck10.symbols

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class StringIterator {
1616
};
1717
}
1818
[Symbol.iterator]() {
19+
>[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(ES5For-ofTypeCheck10.ts, 7, 5))
20+
1921
return this;
2022
>this : Symbol(StringIterator, Decl(ES5For-ofTypeCheck10.ts, 0, 0))
2123
}

tests/baselines/reference/ES5For-ofTypeCheck10.types

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class StringIterator {
2020
};
2121
}
2222
[Symbol.iterator]() {
23+
>[Symbol.iterator] : () => this
2324
>Symbol.iterator : any
2425
>Symbol : any
2526
>iterator : any

tests/baselines/reference/ES5SymbolProperty1.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var obj = {
1313
>obj : Symbol(obj, Decl(ES5SymbolProperty1.ts, 5, 3))
1414

1515
[Symbol.foo]: 0
16+
>[Symbol.foo] : Symbol([Symbol.foo], Decl(ES5SymbolProperty1.ts, 5, 11))
1617
>Symbol.foo : Symbol(SymbolConstructor.foo, Decl(ES5SymbolProperty1.ts, 0, 29))
1718
>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty1.ts, 3, 3))
1819
>foo : Symbol(SymbolConstructor.foo, Decl(ES5SymbolProperty1.ts, 0, 29))

tests/baselines/reference/ES5SymbolProperty1.types

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var obj = {
1414
>{ [Symbol.foo]: 0} : { [Symbol.foo]: number; }
1515

1616
[Symbol.foo]: 0
17+
>[Symbol.foo] : number
1718
>Symbol.foo : string
1819
>Symbol : SymbolConstructor
1920
>foo : string

tests/baselines/reference/ES5SymbolProperty2.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module M {
99
>C : Symbol(C, Decl(ES5SymbolProperty2.ts, 1, 20))
1010

1111
[Symbol.iterator]() { }
12+
>[Symbol.iterator] : Symbol(C[Symbol.iterator], Decl(ES5SymbolProperty2.ts, 3, 20))
1213
>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty2.ts, 1, 7))
1314
}
1415
(new C)[Symbol.iterator];

tests/baselines/reference/ES5SymbolProperty2.types

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module M {
99
>C : C
1010

1111
[Symbol.iterator]() { }
12+
>[Symbol.iterator] : () => void
1213
>Symbol.iterator : any
1314
>Symbol : any
1415
>iterator : any

tests/baselines/reference/ES5SymbolProperty3.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class C {
66
>C : Symbol(C, Decl(ES5SymbolProperty3.ts, 0, 16))
77

88
[Symbol.iterator]() { }
9+
>[Symbol.iterator] : Symbol(C[Symbol.iterator], Decl(ES5SymbolProperty3.ts, 2, 9))
910
>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty3.ts, 0, 3))
1011
}
1112

0 commit comments

Comments
 (0)