Skip to content

Commit

Permalink
Fix / better typing for history location (#1794)
Browse files Browse the repository at this point in the history
* fix: restore string (path) in union type for Location

* chore: add changeset

* chore: better typing for history location

* chore: add changeset
  • Loading branch information
rezrah committed Jan 13, 2022
1 parent 6a8472b commit a8c427d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-jeans-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

replace `Location | Pathname` union type for `to` prop with more appropriate `To`
4 changes: 2 additions & 2 deletions src/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classnames from 'classnames'
import {Location, Pathname} from 'history'
import {To} from 'history'
import React from 'react'
import styled from 'styled-components'
import Box from './Box'
Expand Down Expand Up @@ -54,7 +54,7 @@ function Breadcrumbs({className, children, sx: sxProp}: React.PropsWithChildren<
}

type StyledBreadcrumbsItemProps = {
to?: Location | Pathname
to?: To
selected?: boolean
} & SxProp

Expand Down
4 changes: 2 additions & 2 deletions src/SideNav.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Location, Pathname} from 'history'
import {To} from 'history'

import {get} from './constants'
import styled, {css} from 'styled-components'
Expand Down Expand Up @@ -54,7 +54,7 @@ const SideNav = styled(SideNavBase)<SxProp>`
${sx};
`
type StyledSideNavLinkProps = {
to?: Location | Pathname
to?: To
selected?: boolean
variant?: 'full' | 'normal'
}
Expand Down
4 changes: 2 additions & 2 deletions src/SubNav.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classnames from 'classnames'
import {Location, Pathname} from 'history'
import {To} from 'history'
import React from 'react'
import styled from 'styled-components'
import {get} from './constants'
Expand Down Expand Up @@ -58,7 +58,7 @@ const SubNavLinks = styled.div<SubNavLinksProps>`
`

type StyledSubNavLinkProps = {
to?: Location | Pathname
to?: To
selected?: boolean
} & SxProp

Expand Down
4 changes: 2 additions & 2 deletions src/TabNav.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classnames from 'classnames'
import {Location, Pathname} from 'history'
import {To} from 'history'
import React from 'react'
import styled from 'styled-components'
import {get} from './constants'
Expand Down Expand Up @@ -32,7 +32,7 @@ function TabNav({children, 'aria-label': ariaLabel, ...rest}: TabNavProps) {
}

type StyledTabNavLinkProps = {
to?: Location | Pathname
to?: To
selected?: boolean
} & SxProp

Expand Down
4 changes: 2 additions & 2 deletions src/UnderlineNav.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classnames from 'classnames'
import {Location, Pathname} from 'history'
import {To} from 'history'
import React from 'react'
import styled from 'styled-components'
import {get} from './constants'
Expand Down Expand Up @@ -59,7 +59,7 @@ function UnderlineNav({actions, className, align, children, full, label, theme,
}

type StyledUnderlineNavLinkProps = {
to?: Location | Pathname
to?: To
selected?: boolean
} & SxProp

Expand Down

0 comments on commit a8c427d

Please sign in to comment.