Make Link.to and Button.to more strict

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-08-08 16:12:21 +02:00
parent 5b830da1b1
commit d0eefc499a
3 changed files with 11 additions and 4 deletions
+5
View File
@@ -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.
+3 -2
View File
@@ -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<LinkProps_2, 'to'> &
Omit<LinkProps_3, 'to'> & {
to: string;
component?: ElementType<any>;
noTrack?: boolean;
};
@@ -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<MaterialLinkProps, 'to'> &
Omit<RouterLinkProps, 'to'> & {
to: string;
component?: ElementType<any>;
noTrack?: boolean;
};