Suggestion
π Search Terms
class expression declaration type
β
Viability Checklist
My suggestion meets these guidelines:
β Suggestion
When a class is created by a static method, there doesn't seem to be a way to directly use it as a class type.
π Motivating Example
Implementation:
class BaseClass {
static cloneClass() {
return class extends BaseClass { }
}
}
How I would expect the declaration to look, with the type error present now:
declare class BaseClass {
static cloneClass(): class extends BaseClass {};
// ~~~~~
// Cannot find name 'class'.
}
The declaration actually created:
declare class BaseClass {
static cloneClass(): {
new (): {};
cloneClass(): any;
};
}
π» Use Cases
Similar to #45013: it's difficult to represent class "factories" like this one in type declarations.
Suggestion
π Search Terms
class expression declaration type
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
When a class is created by a static method, there doesn't seem to be a way to directly use it as a class type.
π Motivating Example
Implementation:
How I would expect the declaration to look, with the type error present now:
The declaration actually created:
π» Use Cases
Similar to #45013: it's difficult to represent class "factories" like this one in type declarations.