1

I'd love to do something like this:

function myFunction(arg1: string, arg2: number): boolean {
    //some code here
}

interface myInterface {
    someOtherProperty: string
    myFunction: myFunction // should be the equivalent of (arg1: string, arg2: Number) => boolean
}

Is this possible?

1 Answer 1

2

You can use typeof in a type context to get the type of any value:


function myFunction(arg1: string, arg2: number): boolean {
  return false;
}

interface myInterface {
    someOtherProperty: string
    myFunction: typeof myFunction 
}

Playground Link

Sign up to request clarification or add additional context in comments.

1 Comment

When you use it in a type context, that is. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.