Closed
Description
Bug Report
🔎 Search Terms
destructure, spread, object, array
🕗 Version & Regression Information
Using 4.5.5 but also in nightly playground
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about spread operator
⏯ Playground Link
Playground link with relevant code
💻 Code
type MyType = {test: string}
const list: MyType[] = [{test: "a"}, {test: "b"}];
const x: Record<string, MyType[]> = {
// object shouldn't be allowed?
"hello": {
...list
}
}
console.log(x);
x["hello"].map((el) => el);
// map doesn't exist on object
🙁 Actual behavior
Spreading an array inside an object where an array is expected works, and the type information is then incorrect.
🙂 Expected behavior
Spreading an array inside an object where an array is expected should give a type error.