Closed
Description
TypeScript Version: 2.4.2
export type MyType =
{
id: number;
}
&
{
name: string;
}
&
{
photo:
{
id: number;
}
&
{
url: string;
}
}
export let obj: MyType;
export const photo: typeof obj.photo = {
id: 1,
url: '',
xyz: 1 // Great! This causes an error!
};
export const myInstance: MyType = {
id: 1,
name: '',
photo: {
id: 1,
url: '',
xyz: 2 // Bug? This does not cause an error!!!
}
};
Expected behavior:
I expect all attributions to xyz
to give an error.
Actual behavior:
TypeScript is accepting one of the attributions to xyz
(with value 2).