Reputation: 131
It's possible to create an interface with the following shape:
export interface GenericType<T> {
(data: T): void;
hasLimit?: boolean;
}
But how do I supply an object that implements the interface for it?
I could change the interface to:
export interface GenericType<T> {
callback: (data: T) => void;
hasLimit?: boolean;
}
And supply an object that fits the shape with:
methodname({callback, true})
But how can I supply an object with the boolean parameter without changing the interface?
Upvotes: 0
Views: 146
Reputation: 255105
You cannot create it with a single statement, but instead should declare a variable and use the properties:
const f = (data: string): void => {
console.log(data);
};
f.hasLimit = true;
Upvotes: 1