question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript 4.4.2 breaks react-use

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:11
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
JunyWuuuu91commented, Feb 24, 2022

still seeing this too with 17.3.2 and ts@4.5.4 and vite@2.8.0

9reactions
kamranayubcommented, Nov 29, 2021

Workaround (if NOT using usePermissions) is to import directly

- import { usePrevious } from 'react-use';
+ import usePrevious from 'react-use/lib/usePrevious';

And yes, this should be re-opened since it’s still an issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - TypeScript 4.4
TypeScript lets us describe objects where every property has to have a certain type using index signatures. This allows us to use these...
Read more >
TypeScript 4.4: The Good, The Bad and The Not So Bad
We'll start by summarising the breaking changes. In this release, there are a few of them that aren't major but could still break...
Read more >
Announcing TypeScript 4.4 - Microsoft Developer Blogs
Breaking Changes · lib.d.ts Changes for TypeScript 4.4 · More-Compliant Indirect Calls for Imported Functions · Using unknown in Catch Variables.
Read more >
NPM package cannot be used as a JSX Component
3", "@types/react": "^17.0.44", "typescript": "^4.3.5" "@types/node": "^ ...
Read more >
tss-react - npm
Type safe CSS-in-JS API heavily inspired by react-jss. Latest version: 4.4.2, last published: a day ago. Start using tss-react in your project by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found