From 44f04f3155ff45238c00a176280d6aaf1db3746b Mon Sep 17 00:00:00 2001 From: thebreiflabb Date: Thu, 9 Nov 2023 00:17:50 +0100 Subject: [PATCH] fix: typescript react type resolution in monorepos (#2866) Monorepos with potentially multiple versions of @types/react might resolve the wrong @types/react from within Eufemia With @types/react and @types/react-dom as optional peerDependencies the package manager is able to link the original types package from the app into Eufemia --- packages/dnb-eufemia/package.json | 10 ++++++++++ yarn.lock | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/packages/dnb-eufemia/package.json b/packages/dnb-eufemia/package.json index 6a838b5c7e2..0ce8f85b442 100644 --- a/packages/dnb-eufemia/package.json +++ b/packages/dnb-eufemia/package.json @@ -118,9 +118,19 @@ "what-input": "5.2.10" }, "peerDependencies": { + "@types/react": "^17 || ^18", + "@types/react-dom": "^17 || ^18", "react": "^17 || ^18", "react-dom": "^17 || ^18" }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + }, "devDependencies": { "@babel/cli": "7.22.5", "@babel/core": "7.22.5", diff --git a/yarn.lock b/yarn.lock index b88c9a0363e..d5971f63c77 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3133,8 +3133,15 @@ __metadata: wait-on: "npm:6.0.0" what-input: "npm:5.2.10" peerDependencies: + "@types/react": ^17 || ^18 + "@types/react-dom": ^17 || ^18 react: ^17 || ^18 react-dom: ^17 || ^18 + peerDependenciesMeta: + "@types/react": + optional: true + "@types/react-dom": + optional: true languageName: unknown linkType: soft