mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 02:21:30 -05:00
Merge pull request #31858 from microsoft/fixReadonlyPropertyWidening
Fix readonly property widening
This commit is contained in:
@@ -14630,7 +14630,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createSymbolWithType(source: Symbol, type: Type | undefined) {
|
||||
const symbol = createSymbol(source.flags, source.escapedName);
|
||||
const symbol = createSymbol(source.flags, source.escapedName, getCheckFlags(source) & CheckFlags.Readonly);
|
||||
symbol.declarations = source.declarations;
|
||||
symbol.parent = source.parent;
|
||||
symbol.type = type;
|
||||
|
||||
@@ -200,8 +200,8 @@ declare let p4: readonly [readonly [readonly [readonly [10]]]];
|
||||
declare let x1: {
|
||||
readonly x: 10;
|
||||
readonly y: readonly [20, 30];
|
||||
z: {
|
||||
a: {
|
||||
readonly z: {
|
||||
readonly a: {
|
||||
readonly b: 42;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -281,7 +281,7 @@ let p4 = [[[[10]]]] as const;
|
||||
>10 : 10
|
||||
|
||||
let x1 = { x: 10, y: [20, 30], z: { a: { b: 42 } } } as const;
|
||||
>x1 : { readonly x: 10; readonly y: readonly [20, 30]; z: { a: { readonly b: 42; }; }; }
|
||||
>x1 : { readonly x: 10; readonly y: readonly [20, 30]; readonly z: { readonly a: { readonly b: 42; }; }; }
|
||||
>{ 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; }; }; }
|
||||
>{ x: 10, y: [20, 30], z: { a: { b: 42 } } } : { readonly x: 10; readonly y: readonly [20, 30]; readonly z: { readonly a: { readonly b: 42; }; }; }
|
||||
>x : 10
|
||||
|
||||
Reference in New Issue
Block a user