i'm trying to implement a interface on a class like this:
type TLanguage = "TYPE" | "SCRIPT" // Reusable values
interface AnyInterface {
business: TLanguage
/** MoreTypes */
}
class Anyclass implements AnyInterface{
business = "TYPE"
}
This throws a error :
Property 'business' in type 'Anyclass' is not assignable to the same property in base type 'AnyInterface'. Type 'string' is not assignable to type 'TLanguage'.ts(2416)
Expected behavior is to whenever i set any value of business outside of the TLanguage scope, it would throw a error... It does work when i set it on a variable:
const anyConst: AnyInterface = {
business: "TYPE" //✅
business: "TYPEs" //❌ Type '"TYPEs"' is not assignable to type 'TLanguage'. Did you mean '"TYPE"'?ts(2820)
}