Open Rendalf opened 4 years ago
@ahejlsberg I've been looking at a few of these and don't feel like I have a good handle on our policy on computed property keys in these positions. Are they ever excess? How are they checked?
Too explained this issue on SO with spreading with number
keys.
https://stackoverflow.com/questions/63037175/typescript-some-strange-spread-allowed-that-breaks-typings
Why this works without error:
interface S {
chats: {
[ChatId: number]: {
name: string
messages: []
}
}
}
const s1: S = {
chats: {
[1123]: {
name: 'some',
messages: [],
},
},
}
const s2: S = {
chats: {
...s1,
},
}
console.log('s2', s2)
This definilty gives illegal result: s2 { chats: { chats: { '1123': [Object] } } }
This is likely highly related to https://github.com/microsoft/TypeScript/issues/27273
TypeScript Version: 3.8.3
Search Terms: [type inference], [partial], [record], [object spreading]
Code
Expected behavior: Should throw an error on
...prevPoint
becausePoint
doesn't equal toSpace
.Actual behavior: No error.
Playground Link: https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=17&pc=1#code/C4TwDgpgBACg9gSwHbCgXigbwFBSgDwC4okBXAWwCMIAnXKEYsq27AX221EigGUwAhgGNoGGAJrAEAgDYAeAEoQhcGgBM5zajQA0sRCgB8hztgBmpJEKlwkUAWrXxkwJWtIiaACjAHgxZxQ9XxcASTUmCm1gmggAN35hCGJEkQBKFMERLHoVJABnVDBYuMDUDGL41IgAbRCUcIBdTjxY4FIaOxw8PAA6fsrSvx16PDq-JuJ64BG8Dg4gA
Related Issues: