Comment Comment by leetrout The first example doesn't bother me and I think it's a weak argument. TypeScript allows literals[1] as types[0] so it is trying to use the object as a type.The correct use of: printDog({ breed: "Airedale", age: 3 }) is to explicitly cast it: printDog({ breed: "Airedale", age: 3 } as Dog) [0] https://www.typescriptlang.org/play/index.html?ssl=1&ssc=1&p...[1] https://www.typescriptlang.org/docs/handbook/advanced-types.... parent leetrout 6 years ago
The correct use of:
is to explicitly cast it: [0] https://www.typescriptlang.org/play/index.html?ssl=1&ssc=1&p...[1] https://www.typescriptlang.org/docs/handbook/advanced-types....