I'm trying to create a function that takes ErrorConstructor and message and throws this error with a little bit transformed message. But I get an unexpected error when trying to pass custom error constructor that extends base error:
err<E extends ErrorConstructor>(Err: E, message: any): never {
throw new Err(`'${message}': at line ${this.line}, at column ${this.column}`)
}
class LexerError extends Error {name="LexerError"}
err(LexerError, 'Invalid token: ${some_token}') //here is the error
the error: Argument of type 'typeof LexerError' is not assignable to parameter of type 'ErrorConstructor'. Type 'typeof LexerError' provides no match for the signature '(message?: string | undefined): Error'