You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
obj is inferred as {foo: number, bar: undefined}.
Spreading a setter-only property uses undefined as the property's value.
Likewise the following evaluates to true:
Previously they were skipped. The runtime behaviour is to create a
property of type undefined, unlike (for example) spreading numbers or
other primitives. So now spreading a set-only accessor creates a
property of type undefined:
```ts
const o: { foo: undefined } = { ...{ set foo(v: number) { } } }
```
Notably, `o.foo: undefined` not `number`.
Fixes#26337
* Set-only accessors spread to undefined
Previously they were skipped. The runtime behaviour is to create a
property of type undefined, unlike (for example) spreading numbers or
other primitives. So now spreading a set-only accessor creates a
property of type undefined:
```ts
const o: { foo: undefined } = { ...{ set foo(v: number) { } } }
```
Notably, `o.foo: undefined` not `number`.
Fixes#26337
* Fix isSpreadableProperty oversimplification
TypeScript Version: 3.1.0-dev.20180808
Search Terms:
Code
Expected behavior:
obj
is inferred as{foo: number, bar: undefined}
.Spreading a setter-only property uses
undefined
as the property's value.Likewise the following evaluates to
true
:Actual behavior:
obj
is inferred as{foo: number}
.Playground Link: https://agentcooper.github.io/typescript-play/#code/MYewdgzgLgBCBGArGBeGBvAUDHMBmIIAXDAIwA02uAdLehAKazwCGATgBQBuJYArgFt4DNgEoMAXwmYJAbkxA
Related Issues:
#11596
#21759
#17793
The text was updated successfully, but these errors were encountered: