The following gives error TS2556, how do I fix it?
class Test {
constructor(x: number) {}
}
class Test2 extends Test {
constructor(...args) {
super(...args); // TS2556
}
}
Or if you are using jsdoc with tsc for typechecking:
class Test {
/**
* @param {number} x
*/
constructor(x) {}
}
class Test2 extends Test {
constructor(...args) {
super(...args);
}
}
Use ConstructorParameters<T>
, if you are calling a function you can get away with just Parameters<T>
.
class Test {
constructor(x: number) {}
}
class Test2 extends Test {
constructor(...args: ConstructorParameters<typeof Test>) {
super(...args);
}
}
Or for jsdoc:
class Test {
/**
* @param {number} x
*/
constructor(x) {}
}
class Test2 extends Test {
/**
* @param {ConstructorParameters<typeof Test>} args
*/
constructor(...args) {
super(...args);
}
}