-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
Hey there!
Lately we worked a lot with Typescript and React and we have noticed that nobody has yet made a declaration file for typescript on FreezerJS. We have tried to create a d.ts file ourselves for our project, but we have noticed that all fields of the state can access the functions of the listener, so we can't declare the state as 'any' type.
Here's our code for d.ts file:
declare interface IFreezerOptions{
mutable:boolean;
live:boolean;
freezeInstances:boolean;
}
declare interface IFreezerListener {
on:(eventName: string, cb: (...params:any[]) => void) => void;
once:(eventName: string, cb: (...params:any[]) => void) => void;
off:(eventName: string, cb: (...params:any[]) => void) => void;
emit:(eventName:string, ...params:any[]) => void;
}
declare class Freezer implements IFreezerListener{
new (a: any, b:IFreezerOptions) : Freezer;
set(state:any):void;
set(key:any, state:any):void;
reset(newData:any):void;
get():any;
getEventHub(): IFreezerListener;
on(eventName: string, cb: (...params:any[]) => void) : void;
once(eventName: string, cb: (...params:any[]) => void) : void;
off(eventName: string, cb: (...params:any[]) => void) : void;
emit(eventName:string, ...params:any[]) : void;
}
declare namespace Freezer{
}
export = Freezer;
Is there any way to type the library by ourselvers or are we just squealing because it's impossible?
Thanks a lot to everybody!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels