Skip to content

Commit 241de73

Browse files
authored
Merge pull request microsoft#34496 from microsoft/fix34272
Properly attach alias symbol to `readonly T[]` types
2 parents 1bfc472 + 9c073ab commit 241de73

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12438,7 +12438,7 @@ namespace ts {
1243812438

1243912439
function getAliasSymbolForTypeNode(node: TypeNode) {
1244012440
let host = node.parent;
12441-
while (isParenthesizedTypeNode(host)) {
12441+
while (isParenthesizedTypeNode(host) || isTypeOperatorNode(host) && host.operator === SyntaxKind.ReadonlyKeyword) {
1244212442
host = host.parent;
1244312443
}
1244412444
return isTypeAlias(host) ? getSymbolOfNode(host) : undefined;

tests/baselines/reference/readonlyArraysAndTuples.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type T11 = Array<string>;
66
>T11 : T11
77

88
type T12 = readonly string[];
9-
>T12 : readonly string[]
9+
>T12 : T12
1010

1111
type T13 = ReadonlyArray<string>;
1212
>T13 : T13
@@ -15,7 +15,7 @@ type T20 = [number, number];
1515
>T20 : T20
1616

1717
type T21 = readonly [number, number];
18-
>T21 : readonly [number, number]
18+
>T21 : T21
1919

2020
type T30 = readonly string; // Error
2121
>T30 : string
@@ -24,10 +24,10 @@ type T31<T> = readonly T; // Error
2424
>T31 : T
2525

2626
type T32 = readonly readonly string[]; // Error
27-
>T32 : readonly string[]
27+
>T32 : T32
2828

2929
type T33 = readonly Array<string>; // Error
30-
>T33 : string[]
30+
>T33 : T33
3131

3232
function f1(ma: string[], ra: readonly string[], mt: [string, string], rt: readonly [string, string]) {
3333
>f1 : (ma: string[], ra: readonly string[], mt: [string, string], rt: readonly [string, string]) => void

tests/baselines/reference/readonlyArraysAndTuples2.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type T11 = Array<string>;
66
>T11 : T11
77

88
type T12 = readonly string[];
9-
>T12 : readonly string[]
9+
>T12 : T12
1010

1111
type T13 = ReadonlyArray<string>;
1212
>T13 : T13
@@ -15,7 +15,7 @@ type T20 = [number, number];
1515
>T20 : T20
1616

1717
type T21 = readonly [number, number];
18-
>T21 : readonly [number, number]
18+
>T21 : T21
1919

2020
declare function f1(ma: string[], ra: readonly string[], mt: [string, string], rt: readonly [string, string]): readonly [string, string];
2121
>f1 : (ma: string[], ra: readonly string[], mt: [string, string], rt: readonly [string, string]) => readonly [string, string]

tests/baselines/reference/recursiveTypeReferences1.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ type T10 = T10[];
347347
>T10 : T10
348348

349349
type T11 = readonly T11[];
350-
>T11 : readonly (readonly (readonly (readonly (readonly (readonly (readonly (readonly (readonly (readonly (readonly any[])[])[])[])[])[])[])[])[])[])[]
350+
>T11 : T11
351351

352352
type T12 = (T12)[];
353353
>T12 : T12

0 commit comments

Comments
 (0)