Skip to content

Commit cbae69b

Browse files
committed
Issue 3: react-use Type Definitions (API Reports Build)
Root Cause: react-use@17.6.0 has outdated TypeScript definitions incompatible with React 18 / TypeScript 5.7: - RefForwardingComponent was removed in React 18 types - IDevicePermissionDescriptor type incompatibility with PermissionName Investigation: Checked for newer versions - latest is still 17.6.0 (Dec 2024), fix PR was closed without merging, library appears unmaintained Fix: Created yarn patch for react-use@17.6.0: - Replaced RefForwardingComponent → ForwardRefRenderFunction - Fixed IDevicePermissionDescriptor by removing incompatible extends PermissionDescriptor Files Patched: - .yarn/patches/react-use-npm-17.6.0-327459097c.patch - Automatically added to package.json resolutions Result: ✓ yarn build:api-reports plugins/ai-experience succeeds
1 parent 32725aa commit cbae69b

5 files changed

Lines changed: 64 additions & 12 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
diff --git a/lib/useEnsuredForwardedRef.d.ts b/lib/useEnsuredForwardedRef.d.ts
2+
index 2512358f099351655d309c3dbff1a14bfae945ba..7f008983b8e9b9bc2f0478dd6f11a443138f5ae6 100644
3+
--- a/lib/useEnsuredForwardedRef.d.ts
4+
+++ b/lib/useEnsuredForwardedRef.d.ts
5+
@@ -1,3 +1,3 @@
6+
-import { ForwardRefExoticComponent, MutableRefObject, PropsWithoutRef, RefAttributes, RefForwardingComponent } from 'react';
7+
+import { ForwardRefExoticComponent, ForwardRefRenderFunction, MutableRefObject, PropsWithoutRef, RefAttributes } from 'react';
8+
export default function useEnsuredForwardedRef<T>(forwardedRef: MutableRefObject<T>): MutableRefObject<T>;
9+
-export declare function ensuredForwardRef<T, P = {}>(Component: RefForwardingComponent<T, P>): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
10+
+export declare function ensuredForwardRef<T, P = {}>(Component: ForwardRefRenderFunction<T, P>): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
11+
diff --git a/lib/usePermission.d.ts b/lib/usePermission.d.ts
12+
index d475392903712816e991e3722f548e0e3fd0c36e..7297147693dfa090c1a32f495557998986307e28 100644
13+
--- a/lib/usePermission.d.ts
14+
+++ b/lib/usePermission.d.ts
15+
@@ -7,7 +7,7 @@ interface IMidiPermissionDescriptor extends PermissionDescriptor {
16+
name: 'midi';
17+
sysex?: boolean;
18+
}
19+
-interface IDevicePermissionDescriptor extends PermissionDescriptor {
20+
+interface IDevicePermissionDescriptor {
21+
name: 'camera' | 'microphone' | 'speaker';
22+
deviceId?: string;
23+
}

workspaces/ai-integrations/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
"resolutions": {
5252
"@types/react": "^18",
5353
"@types/react-dom": "^18",
54-
"isolated-vm": "^6.0.1"
54+
"isolated-vm": "^6.0.1",
55+
"react-use@npm:^17.2.4": "patch:react-use@npm%3A17.6.0#~/.yarn/patches/react-use-npm-17.6.0-327459097c.patch",
56+
"react-use@npm:^17.3.2": "patch:react-use@npm%3A17.6.0#~/.yarn/patches/react-use-npm-17.6.0-327459097c.patch",
57+
"react-use@npm:^17.5.0": "patch:react-use@npm%3A17.6.0#~/.yarn/patches/react-use-npm-17.6.0-327459097c.patch",
58+
"react-use@npm:^17.4.0": "patch:react-use@npm%3A17.6.0#~/.yarn/patches/react-use-npm-17.6.0-327459097c.patch"
5559
},
5660
"prettier": "@spotify/prettier-config",
5761
"lint-staged": {

workspaces/ai-integrations/plugins/ai-experience/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@red-hat-developer-hub/backstage-plugin-ai-experience-common": "workspace:^",
4949
"@tanstack/react-query": "^5.71.0",
5050
"he": "^1.2.0",
51-
"react-use": "^17.2.4",
51+
"react-use": "patch:react-use@npm%3A17.6.0#~/.yarn/patches/react-use-npm-17.6.0-327459097c.patch",
5252
"xml2js": "^0.6.2"
5353
},
5454
"peerDependencies": {

workspaces/ai-integrations/plugins/ai-experience/report.api.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { BackstagePlugin } from '@backstage/core-plugin-api';
77
import { IconComponent } from '@backstage/core-plugin-api';
88
import { JSX as JSX_2 } from 'react/jsx-runtime';
99
import { RouteRef } from '@backstage/core-plugin-api';
10-
import { TranslationRef } from '@backstage/core-plugin-api/alpha';
11-
import { TranslationResource } from '@backstage/core-plugin-api/alpha';
10+
import { TranslationRef } from '@backstage/frontend-plugin-api';
11+
import { TranslationResource } from '@backstage/frontend-plugin-api';
1212

1313
// @public
1414
export const AiExperiencePage: () => JSX_2.Element;
@@ -28,11 +28,6 @@ export const aiExperienceTranslationRef: TranslationRef<
2828
{
2929
readonly 'page.title': string;
3030
readonly 'page.subtitle': string;
31-
readonly 'news.pageTitle': string;
32-
readonly 'news.fetchingRssFeed': string;
33-
readonly 'news.noContentAvailable': string;
34-
readonly 'news.noContentDescription': string;
35-
readonly 'news.noRssContent': string;
3631
readonly 'learn.learn.title': string;
3732
readonly 'learn.learn.description': string;
3833
readonly 'learn.learn.cta': string;
@@ -42,12 +37,17 @@ export const aiExperienceTranslationRef: TranslationRef<
4237
readonly 'learn.explore.title': string;
4338
readonly 'learn.explore.description': string;
4439
readonly 'learn.explore.cta': string;
40+
readonly 'news.pageTitle': string;
41+
readonly 'news.fetchingRssFeed': string;
42+
readonly 'news.noContentAvailable': string;
43+
readonly 'news.noContentDescription': string;
44+
readonly 'news.noRssContent': string;
45+
readonly 'modal.cancel': string;
4546
readonly 'modal.title.preview': string;
4647
readonly 'modal.title.edit': string;
4748
readonly 'modal.close': string;
4849
readonly 'modal.edit': string;
4950
readonly 'modal.save': string;
50-
readonly 'modal.cancel': string;
5151
readonly 'common.template': string;
5252
readonly 'common.latest': string;
5353
readonly 'common.more': string;

workspaces/ai-integrations/yarn.lock

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10568,7 +10568,7 @@ __metadata:
1056810568
he: "npm:^1.2.0"
1056910569
msw: "npm:^1.0.0"
1057010570
react: "npm:^16.14.0 || ^17.0.0 || ^18.0.0"
10571-
react-use: "npm:^17.2.4"
10571+
react-use: "patch:react-use@npm%3A17.6.0#~/.yarn/patches/react-use-npm-17.6.0-327459097c.patch"
1057210572
xml2js: "npm:^0.6.2"
1057310573
peerDependencies:
1057410574
react: ^16.14.0 || ^17.0.0 || ^18.0.0
@@ -29456,7 +29456,7 @@ __metadata:
2945629456
languageName: node
2945729457
linkType: hard
2945829458

29459-
"react-use@npm:^17.2.4, react-use@npm:^17.3.2, react-use@npm:^17.4.0, react-use@npm:^17.5.0":
29459+
"react-use@npm:17.6.0":
2946029460
version: 17.6.0
2946129461
resolution: "react-use@npm:17.6.0"
2946229462
dependencies:
@@ -29481,6 +29481,31 @@ __metadata:
2948129481
languageName: node
2948229482
linkType: hard
2948329483

29484+
"react-use@patch:react-use@npm%3A17.6.0#~/.yarn/patches/react-use-npm-17.6.0-327459097c.patch":
29485+
version: 17.6.0
29486+
resolution: "react-use@patch:react-use@npm%3A17.6.0#~/.yarn/patches/react-use-npm-17.6.0-327459097c.patch::version=17.6.0&hash=b14c09"
29487+
dependencies:
29488+
"@types/js-cookie": "npm:^2.2.6"
29489+
"@xobotyi/scrollbar-width": "npm:^1.9.5"
29490+
copy-to-clipboard: "npm:^3.3.1"
29491+
fast-deep-equal: "npm:^3.1.3"
29492+
fast-shallow-equal: "npm:^1.0.0"
29493+
js-cookie: "npm:^2.2.1"
29494+
nano-css: "npm:^5.6.2"
29495+
react-universal-interface: "npm:^0.6.2"
29496+
resize-observer-polyfill: "npm:^1.5.1"
29497+
screenfull: "npm:^5.1.0"
29498+
set-harmonic-interval: "npm:^1.0.1"
29499+
throttle-debounce: "npm:^3.0.1"
29500+
ts-easing: "npm:^0.2.0"
29501+
tslib: "npm:^2.1.0"
29502+
peerDependencies:
29503+
react: "*"
29504+
react-dom: "*"
29505+
checksum: 10c0/2de334f6ff68841b089b23f811955ea0221c317bac8434ff40faedbb3425816d511e897fc9bb9228b64f1cfb3f5d94f10d8e3ad050687b957f26f97e7da9e0d9
29506+
languageName: node
29507+
linkType: hard
29508+
2948429509
"react-virtualized-auto-sizer@npm:^1.0.11":
2948529510
version: 1.0.25
2948629511
resolution: "react-virtualized-auto-sizer@npm:1.0.25"

0 commit comments

Comments
 (0)