You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a real problem or use-case?
Utility type to get constructor params from abstract class. TS built-in ConstructorParameters does not work on abstract class type since it's not constructible.
abstractclassAbstractBase{constructor(foo: string,bar: number){}}classChildextendsAbstractBase{constructor(...args: ConstructorParameters<typeofAbstractBase>){super(...args)}}/** * Error: * Type 'typeof AbstractBase' does not satisfy the constraint 'new (...args: any) => any'. * Cannot assign an abstract constructor type to a non-abstract constructor type.ts(2344) */
Describe a solution including usage in code example
abstractclassAbstractBase{constructor(foo: string,bar: number){}}classChildextendsAbstractBase{// now it works!constructor(...args: AbstractConstructorParameters<typeofAbstractBase>){super(...args)}}
Who does this impact? Who is this for?
Typescript user, generally useful in OOP.
Credit
Found this workaround here, which in turn refers to this reddit post by u/adamuso
The text was updated successfully, but these errors were encountered:
Is your feature request related to a real problem or use-case?
Utility type to get constructor params from abstract class. TS built-in
ConstructorParameters
does not work on abstract class type since it's not constructible.Describe a solution including usage in code example
Solution:
Usage:
Who does this impact? Who is this for?
Typescript user, generally useful in OOP.
Credit
Found this workaround here, which in turn refers to this reddit post by u/adamuso
The text was updated successfully, but these errors were encountered: