TypeScript Version: 3.8.2
Search Terms: ConstructorParameters, overload
Code
interface Options {
a: string;
b: string;
}
class Foo {
constructor(a: string, b: string);
constructor(options: Options);
constructor(options: Options | string, b?: string) {
// implement
}
}
// Expected: type Params = [Options] | [string, string]
// Actual: type Params = [Options]
type Params = ConstructorParameters<typeof Foo>;
const paramArray: Params = ['foo', 'bar']; // error
const paramObj: Params = [{ a: 'foo', b: 'bar' }]; // ok
Expected behavior:
type Params = [Options] | [string, string]
Actual behavior:
Playground Link: playground link
Related Issues: