Test that spread removes readonly from properties
This commit is contained in:
parent
1fc45d3d8b
commit
6879bc1ea1
4 changed files with 78 additions and 0 deletions
22
tests/baselines/reference/spreadTypeRemovesReadonly.js
Normal file
22
tests/baselines/reference/spreadTypeRemovesReadonly.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
//// [spreadTypeRemovesReadonly.ts]
|
||||
interface ReadonlyData {
|
||||
readonly value: string;
|
||||
}
|
||||
|
||||
const data: ReadonlyData = { value: 'foo' };
|
||||
const clone = { ...data };
|
||||
clone.value = 'bar';
|
||||
|
||||
|
||||
//// [spreadTypeRemovesReadonly.js]
|
||||
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
var data = { value: 'foo' };
|
||||
var clone = __assign({}, data);
|
||||
clone.value = 'bar';
|
22
tests/baselines/reference/spreadTypeRemovesReadonly.symbols
Normal file
22
tests/baselines/reference/spreadTypeRemovesReadonly.symbols
Normal file
|
@ -0,0 +1,22 @@
|
|||
=== tests/cases/compiler/spreadTypeRemovesReadonly.ts ===
|
||||
interface ReadonlyData {
|
||||
>ReadonlyData : Symbol(ReadonlyData, Decl(spreadTypeRemovesReadonly.ts, 0, 0))
|
||||
|
||||
readonly value: string;
|
||||
>value : Symbol(ReadonlyData.value, Decl(spreadTypeRemovesReadonly.ts, 0, 24))
|
||||
}
|
||||
|
||||
const data: ReadonlyData = { value: 'foo' };
|
||||
>data : Symbol(data, Decl(spreadTypeRemovesReadonly.ts, 4, 5))
|
||||
>ReadonlyData : Symbol(ReadonlyData, Decl(spreadTypeRemovesReadonly.ts, 0, 0))
|
||||
>value : Symbol(value, Decl(spreadTypeRemovesReadonly.ts, 4, 28))
|
||||
|
||||
const clone = { ...data };
|
||||
>clone : Symbol(clone, Decl(spreadTypeRemovesReadonly.ts, 5, 5))
|
||||
>data : Symbol(data, Decl(spreadTypeRemovesReadonly.ts, 4, 5))
|
||||
|
||||
clone.value = 'bar';
|
||||
>clone.value : Symbol(value, Decl(spreadTypeRemovesReadonly.ts, 0, 24))
|
||||
>clone : Symbol(clone, Decl(spreadTypeRemovesReadonly.ts, 5, 5))
|
||||
>value : Symbol(value, Decl(spreadTypeRemovesReadonly.ts, 0, 24))
|
||||
|
27
tests/baselines/reference/spreadTypeRemovesReadonly.types
Normal file
27
tests/baselines/reference/spreadTypeRemovesReadonly.types
Normal file
|
@ -0,0 +1,27 @@
|
|||
=== tests/cases/compiler/spreadTypeRemovesReadonly.ts ===
|
||||
interface ReadonlyData {
|
||||
>ReadonlyData : ReadonlyData
|
||||
|
||||
readonly value: string;
|
||||
>value : string
|
||||
}
|
||||
|
||||
const data: ReadonlyData = { value: 'foo' };
|
||||
>data : ReadonlyData
|
||||
>ReadonlyData : ReadonlyData
|
||||
>{ value: 'foo' } : { value: string; }
|
||||
>value : string
|
||||
>'foo' : "foo"
|
||||
|
||||
const clone = { ...data };
|
||||
>clone : { value: string; }
|
||||
>{ ...data } : { value: string; }
|
||||
>data : ReadonlyData
|
||||
|
||||
clone.value = 'bar';
|
||||
>clone.value = 'bar' : "bar"
|
||||
>clone.value : string
|
||||
>clone : { value: string; }
|
||||
>value : string
|
||||
>'bar' : "bar"
|
||||
|
7
tests/cases/compiler/spreadTypeRemovesReadonly.ts
Normal file
7
tests/cases/compiler/spreadTypeRemovesReadonly.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
interface ReadonlyData {
|
||||
readonly value: string;
|
||||
}
|
||||
|
||||
const data: ReadonlyData = { value: 'foo' };
|
||||
const clone = { ...data };
|
||||
clone.value = 'bar';
|
Loading…
Reference in a new issue