2

Is it possible create an object that implements the following interface:

interface I {
    (): string;
    new(): any;
}

I saw that it is possible to implement an interface having a call signature and some fields from this question: Implementing TypeScript interface with bare function signature plus other fields

1 Answer 1

0

After looking around, it is clearly possible for an object to implement the an interface with both a constructor signature and a call signature:

https://github.com/Microsoft/TypeScript/blob/master/lib/lib.d.ts#L142 is an example of this.

The underlying function seems to be the same, albeit called in two different ways:

new Object(3);

and

Object(3);
Sign up to request clarification or add additional context in comments.

Comments

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.