As described here: Declare class type with TypeScript (pass class as parameter) i can pass a class type as parameter.
There is a problem.
export namespace customCommand {
export class Command {
public constructor(parameter?: any) {
}
}
export function register(command: typeof Command) {
}
}
When i do this
customCommand.register(Map)
or
customCommand.register(Object)
There is no errors. I know that typeof Command
and typeof Map
both return the same result.
But how can i protect this and pass only Command
type?