stalniy / casl

CASL is an isomorphic authorization JavaScript library which restricts what resources a given user is allowed to access
https://casl.js.org/
MIT License
5.74k stars 257 forks source link

@casl/react Breaks React Type #920

Closed enchorb closed 2 weeks ago

enchorb commented 1 month ago

I am using @casl/react in a React Native project. For some reason instead of React types resolving from react (namespace React). They are resolving from @casl/react (module module:react).

After further investigation this is because of the contextApiPatch.d.ts which does:

declare module 'react' {
  export type Consumer<T> = any;
}

I am using patch-package to get rid of this but would be nice for an update to the package itself.

stalniy commented 2 weeks ago

contextApiPatch.d.ts is not imported by any of the modules, it's kind of helper for older versions of React and users need to manually include it into their tsconfig.json.

For some reason React.Native, includes this file, check your tsconfig, maybe it's because include option is too greedy. If so, try to add this file into exclude