Skip to content

Commit 6a8472b

Browse files
authored
fix: restore string (pathname) in union type for previous LocationDescriptor (#1791)
* fix: restore string (path) in union type for Location
1 parent 2d5f64e commit 6a8472b

File tree

7 files changed

+17
-12
lines changed

7 files changed

+17
-12
lines changed

.changeset/unlucky-jobs-tickle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Fix type errors due to missing pathname (string) in union type for LocationDescriptor

src/Breadcrumbs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classnames from 'classnames'
2-
import {Location} from 'history'
2+
import {Location, Pathname} from 'history'
33
import React from 'react'
44
import styled from 'styled-components'
55
import Box from './Box'
@@ -54,7 +54,7 @@ function Breadcrumbs({className, children, sx: sxProp}: React.PropsWithChildren<
5454
}
5555

5656
type StyledBreadcrumbsItemProps = {
57-
to?: Location
57+
to?: Location | Pathname
5858
selected?: boolean
5959
} & SxProp
6060

src/Header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import {Location} from 'history'
1+
import {Location, Pathname} from 'history'
22
import styled, {css} from 'styled-components'
33
import {get} from './constants'
44
import sx, {SxProp} from './sx'
55
import {ComponentProps} from './utils/types'
66

77
type StyledHeaderItemProps = {full?: boolean} & SxProp
88
type StyledHeaderProps = SxProp
9-
type StyledHeaderLinkProps = {to?: Location} & SxProp
9+
type StyledHeaderLinkProps = {to?: Location | Pathname} & SxProp
1010

1111
const Header = styled.div<StyledHeaderProps>`
1212
z-index: 32;

src/SideNav.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Location} from 'history'
1+
import {Location, Pathname} from 'history'
22

33
import {get} from './constants'
44
import styled, {css} from 'styled-components'
@@ -54,7 +54,7 @@ const SideNav = styled(SideNavBase)<SxProp>`
5454
${sx};
5555
`
5656
type StyledSideNavLinkProps = {
57-
to?: Location
57+
to?: Location | Pathname
5858
selected?: boolean
5959
variant?: 'full' | 'normal'
6060
}

src/SubNav.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classnames from 'classnames'
2-
import {Location} from 'history'
2+
import {Location, Pathname} from 'history'
33
import React from 'react'
44
import styled from 'styled-components'
55
import {get} from './constants'
@@ -58,7 +58,7 @@ const SubNavLinks = styled.div<SubNavLinksProps>`
5858
`
5959

6060
type StyledSubNavLinkProps = {
61-
to?: Location
61+
to?: Location | Pathname
6262
selected?: boolean
6363
} & SxProp
6464

src/TabNav.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classnames from 'classnames'
2-
import {Location} from 'history'
2+
import {Location, Pathname} from 'history'
33
import React from 'react'
44
import styled from 'styled-components'
55
import {get} from './constants'
@@ -32,7 +32,7 @@ function TabNav({children, 'aria-label': ariaLabel, ...rest}: TabNavProps) {
3232
}
3333

3434
type StyledTabNavLinkProps = {
35-
to?: Location
35+
to?: Location | Pathname
3636
selected?: boolean
3737
} & SxProp
3838

src/UnderlineNav.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classnames from 'classnames'
2-
import {Location} from 'history'
2+
import {Location, Pathname} from 'history'
33
import React from 'react'
44
import styled from 'styled-components'
55
import {get} from './constants'
@@ -59,7 +59,7 @@ function UnderlineNav({actions, className, align, children, full, label, theme,
5959
}
6060

6161
type StyledUnderlineNavLinkProps = {
62-
to?: Location
62+
to?: Location | Pathname
6363
selected?: boolean
6464
} & SxProp
6565

0 commit comments

Comments
 (0)