why can in TypeScript a possible number value in an interface be converted to a not possible number value in a class implementation?
问题 Today I ran into an unexpected TypeScript compiler behaviour. I'm wondering if it's a bug or a feature. Probably it will be the last one, but then I would like to know the rationale behind it. If I declare an interface method with a parameter that can be a string | number , and create a class that implements that interface, then the class method can make that parameter only string . This leads to a situation where the class implementation is not expecting a number, but the compiler allows