TypeScript Version:
TypeScript 2.2.1
Code
interface TestProps {
foo: string;
bar: string;
}
function test(mode: number, vars: TestProps): TestProps {
switch (mode) {
case 1:
return {
foo: 'a',
bar: 'b',
other: 'c', // This is an error
};
case 2:
return {
...vars,
other: 'c', // This SHOULD be an error
}
}
return {
foo: 'a',
bar: 'b',
}
}
Expected behavior:
The spread operator with an unknown attribute should show a type error.
Actual behavior:
The spread operator with an unknown attribute does not show a type error.
TypeScript Version:
TypeScript 2.2.1
Code
Expected behavior:
The spread operator with an unknown attribute should show a type error.
Actual behavior:
The spread operator with an unknown attribute does not show a type error.