Closed
Description
TypeScript Version: 3.1.4
Search Terms:
union type
Code
export type basetype = {
id: string;
}
export type supertype1 = basetype & {}
export type supertype2 = basetype & {
key1: any;
key2: any;
}
function myfun(p: supertype2 | supertype1) {
return
}
myfun( {
id: '',
key1: '',
})
Expected behavior:
{
id: '',
key1: '',
} is not supertype1 or supertype2, when it is used to be a parameter of myfun, typescript should report an error.
Actual behavior:
there is no error.