Closed
Description
I wish I could turn duck-typing off sometimes because it leads to bugs that very hard to detect.
For example:
Suppose I have 2 interfaces with the same surface but completely unrelated sematics:
interface Chicken {
id: number;
name: string;
}
interface JetPlane {
id: number;
name: string;
}
then doing the following is completely fine in TypeScript:
var chicken : Chicken = { id: 1, name: 'Thomas' };
var plane: JetPlane = { id: 2, name: 'F 35' };
chicken = plane;
I wish there was an option to prevent such assignment from being valid.