From d0eefc499a199f23ea421d21a3110cdd2c3ea595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 8 Aug 2022 16:12:21 +0200 Subject: [PATCH] Make Link.to and Button.to more strict MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/tasty-falcons-press.md | 5 +++++ packages/core-components/api-report.md | 5 +++-- packages/core-components/src/components/Link/Link.tsx | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .changeset/tasty-falcons-press.md diff --git a/.changeset/tasty-falcons-press.md b/.changeset/tasty-falcons-press.md new file mode 100644 index 0000000000..288f527e17 --- /dev/null +++ b/.changeset/tasty-falcons-press.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-components': minor +--- + +Made the `to` prop of `Button` and `Link` more strict, only supporting plain strings. It used to be the case that this prop was unexpectedly too liberal, making it look like we supported the complex `react-router-dom` object form of the parameter as well, which led to unexpected results at runtime. diff --git a/packages/core-components/api-report.md b/packages/core-components/api-report.md index 4e3820967a..1cdba47257 100644 --- a/packages/core-components/api-report.md +++ b/packages/core-components/api-report.md @@ -613,8 +613,9 @@ export const Link: (props: LinkProps) => JSX.Element; // Warning: (ae-missing-release-tag) "LinkProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export type LinkProps = LinkProps_2 & - LinkProps_3 & { +export type LinkProps = Omit & + Omit & { + to: string; component?: ElementType; noTrack?: boolean; }; diff --git a/packages/core-components/src/components/Link/Link.tsx b/packages/core-components/src/components/Link/Link.tsx index 22b203d157..92ac92daad 100644 --- a/packages/core-components/src/components/Link/Link.tsx +++ b/packages/core-components/src/components/Link/Link.tsx @@ -47,8 +47,9 @@ const useStyles = makeStyles( export const isExternalUri = (uri: string) => /^([a-z+.-]+):/.test(uri); -export type LinkProps = MaterialLinkProps & - RouterLinkProps & { +export type LinkProps = Omit & + Omit & { + to: string; component?: ElementType; noTrack?: boolean; };