π Search Terms
spread, computed property, unsoundness
π Version & Regression Information
For any TS version
β― Playground Link
LINK
π» Code
type MyKey = 'key-1' | 'key-2'
interface Obj {
a: number
}
type MyRecord = Record<MyKey, Obj>
declare const someRecord: MyRecord
declare const key: MyKey
const overriden: MyRecord = {
...someRecord,
[key]: 'anything is oke here, why?'
}
π Actual behavior
No type check errors
π Expected behavior
On line 14, we assign string ''anything is oke here, why?'' as a value of a MyRecord type, whose value are typed as interface with one number property. This should lead to error since in runtime the record no longer will have values of type Obj
Additional information about the issue
No response
π Search Terms
spread, computed property, unsoundness
π Version & Regression Information
For any TS version
β― Playground Link
LINK
π» Code
π Actual behavior
No type check errors
π Expected behavior
On line 14, we assign string ''anything is oke here, why?'' as a value of a MyRecord type, whose value are typed as interface with one number property. This should lead to error since in runtime the record no longer will have values of type Obj
Additional information about the issue
No response