-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
I am trying to define a function overload with mulitple optinal arguments, but can not seems to get the syntax right (see below example). Currently I am using the following signature:
function test (a:()=>void, b?:(Object|boolean), c?:boolean)
But this is misleading, because test(noop, true, true)
is not a valid call signature.
Is there a way to achieve this in TS? I am having a tough time to get this to work and couldn't find a solution on SO/Google.
TypeScript Version:
1.8.9
Code
function test (a:()=>void, b?:boolean);
function test (a:()=>void, b?:Object);
function test (a:()=>void, b:Object, c?:boolean) {
/.../
}
const noop = () => {};
test( noop );
test( noop, {} );
test( noop, false );
test( noop, {}, false ); // Supplied parameters do not match any signature of call target.
Expected behavior:
All function calls are valid.
Actual behavior:
Function with 3 arguments is not callable.
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code