Here an example
interface ICommandHandler<T> {
type: string // how to ensure string == T.name ?
handle(command: T): void;
}
interface ICommand {}
class CreateTaskCommand implements ICommand{}
class CreateTaskCommandHandler implements ICommandHandler<CreateTaskCommand> {
type = "CreateTaskCommanD" // typo
handle(command: CreateTaskCommand) {}
}
My goal is to ensure type
property equals CreateTaskCommand
string in CreateTaskCommandHandler
.
My previous example didn't raise a typescript error.