Skip to content

Commit 43a282d

Browse files
authored
Merge pull request #31858 from microsoft/fixReadonlyPropertyWidening
Fix readonly property widening
2 parents d023427 + 0ca078b commit 43a282d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14630,7 +14630,7 @@ namespace ts {
1463014630
}
1463114631

1463214632
function createSymbolWithType(source: Symbol, type: Type | undefined) {
14633-
const symbol = createSymbol(source.flags, source.escapedName);
14633+
const symbol = createSymbol(source.flags, source.escapedName, getCheckFlags(source) & CheckFlags.Readonly);
1463414634
symbol.declarations = source.declarations;
1463514635
symbol.parent = source.parent;
1463614636
symbol.type = type;

tests/baselines/reference/constAssertions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ declare let p4: readonly [readonly [readonly [readonly [10]]]];
200200
declare let x1: {
201201
readonly x: 10;
202202
readonly y: readonly [20, 30];
203-
z: {
204-
a: {
203+
readonly z: {
204+
readonly a: {
205205
readonly b: 42;
206206
};
207207
};

tests/baselines/reference/constAssertions.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ let p4 = [[[[10]]]] as const;
281281
>10 : 10
282282

283283
let x1 = { x: 10, y: [20, 30], z: { a: { b: 42 } } } as const;
284-
>x1 : { readonly x: 10; readonly y: readonly [20, 30]; z: { a: { readonly b: 42; }; }; }
284+
>x1 : { readonly x: 10; readonly y: readonly [20, 30]; readonly z: { readonly a: { readonly b: 42; }; }; }
285285
>{ x: 10, y: [20, 30], z: { a: { b: 42 } } } as const : { readonly x: 10; readonly y: readonly [20, 30]; readonly z: { readonly a: { readonly b: 42; }; }; }
286286
>{ x: 10, y: [20, 30], z: { a: { b: 42 } } } : { readonly x: 10; readonly y: readonly [20, 30]; readonly z: { readonly a: { readonly b: 42; }; }; }
287287
>x : 10

0 commit comments

Comments
 (0)