From 66a1456286bd9d43dc1132cb32103e0bf9bb1371 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 19 Jan 2022 22:25:49 +0100 Subject: [PATCH] changesets: add tip for handling react-use error when upgrading TypeScript Signed-off-by: Patrik Oldsberg --- .changeset/clever-olives-shake.md | 20 ++++++++++++++++++++ .changeset/stupid-baboons-hug.md | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/.changeset/clever-olives-shake.md b/.changeset/clever-olives-shake.md index bb3641923d..2dd0bac179 100644 --- a/.changeset/clever-olives-shake.md +++ b/.changeset/clever-olives-shake.md @@ -38,3 +38,23 @@ try { } } ``` + +Yet another issue you might run into when upgrading TypeScript is incompatibilities in the types from `react-use`. The error you would run into looks something like this: + +```plain +node_modules/react-use/lib/usePermission.d.ts:1:54 - error TS2304: Cannot find name 'DevicePermissionDescriptor'. + +1 declare type PermissionDesc = PermissionDescriptor | DevicePermissionDescriptor | MidiPermissionDescriptor | PushPermissionDescriptor; +``` + +If you encounter this error, the simplest fix is to replace full imports of `react-use` with more specific ones. For example, the following: + +```ts +import { useAsync } from 'react-use'; +``` + +Would be converted into this: + +```ts +import useAsync from 'react-use/lib/useAsync'; +``` diff --git a/.changeset/stupid-baboons-hug.md b/.changeset/stupid-baboons-hug.md index 22b4ee508f..cc8bf5d8ce 100644 --- a/.changeset/stupid-baboons-hug.md +++ b/.changeset/stupid-baboons-hug.md @@ -40,3 +40,23 @@ try { } } ``` + +Yet another issue you might run into when upgrading TypeScript is incompatibilities in the types from `react-use`. The error you would run into looks something like this: + +```plain +node_modules/react-use/lib/usePermission.d.ts:1:54 - error TS2304: Cannot find name 'DevicePermissionDescriptor'. + +1 declare type PermissionDesc = PermissionDescriptor | DevicePermissionDescriptor | MidiPermissionDescriptor | PushPermissionDescriptor; +``` + +If you encounter this error, the simplest fix is to replace full imports of `react-use` with more specific ones. For example, the following: + +```ts +import { useAsync } from 'react-use'; +``` + +Would be converted into this: + +```ts +import useAsync from 'react-use/lib/useAsync'; +```