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.