I updated typescript to version 2.5.3. Now I get many typings errors. I have following simplified situation:
export interface IClassHasMetaImplements { prototype?: any; } export class UserPermissionModel implements IClassHasMetaImplements { public test() { } }
This code statment raise the following error: error TS2559: Type 'UserPermissionModel' has no properties in common with type 'IClassHasMetaImplements'.
Could anyone help me resolving this problem.
Thanks!
The "Property does not exist on type '{}'" error occurs when we try to access or set a property that is not contained in the object's type. To solve the error, type the object properties explicitly or use a type with variable key names.
The error "Type is missing the following properties from type" occurs when the type we assign to a variable is missing some of the properties the actual type of the variable expects. To solve the error, make sure to specify all of the required properties on the object.
TypeScript's weak type detection is being triggered. Because your interface has no required properties, technically any class would satisfy the interface (prior to TypeScript 2.4).
To resolve this error without changing your interface, simply add the optional property to your class:
export interface IClassHasMetaImplements { prototype?: any; } export class UserPermissionModel implements IClassHasMetaImplements { public test() {} prototype?: any; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With