react-use: Typescript 4.4.2 breaks react-use
Version 4.4.2 of Typescript released on August 27th 2021 breaks react-use with:
node_modules/react-use/lib/usePermission.d.ts:1:54 - error TS2304: Cannot find name 'DevicePermissionDescriptor'.
1 declare type PermissionDesc = PermissionDescriptor | DevicePermissionDescriptor | MidiPermissionDescriptor | PushPermissionDescriptor;
~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/react-use/lib/usePermission.d.ts:1:83 - error TS2304: Cannot find name 'MidiPermissionDescriptor'.
1 declare type PermissionDesc = PermissionDescriptor | DevicePermissionDescriptor | MidiPermissionDescriptor | PushPermissionDescriptor;
~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/react-use/lib/usePermission.d.ts:1:110 - error TS2304: Cannot find name 'PushPermissionDescriptor'.
1 declare type PermissionDesc = PermissionDescriptor | DevicePermissionDescriptor | MidiPermissionDescriptor | PushPermissionDescriptor;
~~~~~~~~~~~~~~~~~~~~~~~~
All three:
- DevicePermissionDescriptor
- MidiPermissionDescriptor
- PushPermissionDescriptor
seem to have moved to the [webworker lib]:(https://github.com/microsoft/TypeScript/blob/cec2fda9a53620dc545a2c4d7b0156446ab145b4/lib/lib.webworker.d.ts#L147)
The effect is that the build will break for anyone who uses react-use and runs yarn with a “Compatible with” typescript package of ^4.0.0:
"typescript": "^4.0.0"
For now fixing typescript on 4.3.5 solves this.
Should the usePermissions hook be updated or should a lib definition be added to the tsconfig.json? I’m not sure.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 11
- Comments: 15 (3 by maintainers)
Workaround (if NOT using
usePermissions) is to import directlyAnd yes, this should be re-opened since it’s still an issue.
still seeing this too with
17.3.2andts@4.5.4andvite@2.8.0Should be fixed in
17.3.0, please re-open if bug still presists.This solution works for me.