Currently, declarations for classes consist of an interface for the instance and a declare var for the static side. This is a convoluted way of approaching classes. Instead, Typescript should use declare class, which clarifies the type (since the class is known to be a class, rather than a var object which has a new method and prototype property) and simplifies the definition (only one declaration).
Sample Code
// old
interface Class {
method(): void;
property: number;
}
declare var Class: {
prototype: Class;
new(arg: string): Class;
staticMethod(): void;
}
//new
declare class Class {
method(): void;
property: number;
constructor(arg: string);
static staticMethod(): void;
}
Documentation Link
No response
Currently, declarations for classes consist of an interface for the instance and a
declare varfor the static side. This is a convoluted way of approaching classes. Instead, Typescript should usedeclare class, which clarifies the type (since the class is known to be a class, rather than avarobject which has a new method and prototype property) and simplifies the definition (only one declaration).Sample Code
Documentation Link
No response