1

How can I create an interface which holds functions. I have tried this:

interface ILeonardo {
  addState(state: ILeonardoState),
  addStates(arr: Array<ILeonardoState>)
}

interface ILeonardoState {
  name: string,
  url: string,
  verb: string,
  options: Array<{name: string, status: number, data?: any, delay?: number}>
} 

but then I can't add the return type of addState and addStates.

1 Answer 1

3

Try this (replace the return value that you need)

interface ILeonardo {
   addState(state: ILeonardoState): boolean;
   addStates(arr: Array<ILeonardoState>): void;
}

The function deceleration need to end with semicolon.

http://www.typescriptlang.org/Handbook#interfaces

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.