The following code does not transpile, as I would expect.
interface Interface1 {
a: number;
b: number;
}
const arr: Array<Interface1> = []
arr.push({
a: 1,
b: 1,
c: 1
})
However, as soon as I turn the pushed object into an interface (not matching interface 1), the code successfully transpiles.
interface Interface2 {
a: number;
b: number;
c: number;
}
const test: Interface2 = {
a: 1,
b: 1,
c: 1
}
arr.push(test)
What is going on, and how can I successfully throw a typeError upon this incorrect array push?
Reproduction link: https://codesandbox.io/s/flamboyant-knuth-8lq82?file=/src/index.ts