Merge pull request #31858 from microsoft/fixReadonlyPropertyWidening

Fix readonly property widening
This commit is contained in:
Anders Hejlsberg
2019-06-11 10:08:35 -07:00
committed by GitHub
3 changed files with 4 additions and 4 deletions

View File

@@ -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;

View File

@@ -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;
};
};

View File

@@ -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