Reputation: 9295
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
.
Upvotes: 1
Views: 204
Reputation: 76
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
Upvotes: 3