SunHuawei / with-context

Decorator for new React Context API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does this work nicely with TypeScript?

elie222 opened this issue · comments

Does this work nicely with TypeScript?

No, there aren't type definitions currently.

I added this to a 3rd-party-types.d.ts file just to compile under strict mode, but it could surely be improved 🤠

declare module 'with-context' {
  export var withContext: any;
}

Thanks. Here's one better, but still not too useful yet:

declare module 'with-context' {
  export function withContext(ctx: React.Context, label?: string): (component: any) => any
}

Or even:

declare module 'with-context' {
  export function withContext(ctx: React.Context, label?: string): (WrappedComp: React.ComponentClass<P> | React.FC<P>) => any
}

But wasn't able to figure out replacing the last any with something better yet...