#ConstructorParameters only gives the type of the last overload

3 messages · Page 1 of 1 (latest)

plucky stratus
#
declare class Test {
    constructor(a: number)
    constructor(a: string)
}

// T is [a: string], not [a: string | number]
type T = ConstructorParameters<typeof Test>

class Test2 extends Test {
    constructor(...args: ConstructorParameters<typeof Test>) {
        super(...args)
    }
}

// argument of type "number" is not assignable to type "string"
const t = new Test2(1)

In this example I wish the ConstructorParameters to include all the overload types, instead of just the last overload

plucky stratus
heady parcel