Hello, I am annoyed lately by TypeScript duck typing working on classes! An example:
export class PermissionActionDto {
name: string;
mode: ActionMode;
@Expose({ groups: ["admin"] })
createdAt?: Date;
toString() { return "XD" }
}
// The following line is completely valid for typescript
const act: PermissionActionDto = { name: "List", mode: ActionMode.Allow }
It's perfectly valid for TSC, but decorator Expose won't work on it cause it's not an instance of a class. What's more instanceof won't work either. But there's more! If you define custom toString method, guess what? Yeah, plain object will be valid too, cause every object has toString method.
Is there any ESLint plugin or something that would warn me if I try to assign plain object to class type or another class instance that's not a child of specified type?