Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/unlucky-jobs-tickle.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Fix type errors due to missing pathname (string) in union type for LocationDescriptor
4 changes: 2 additions & 2 deletions src/Breadcrumbs.tsx
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import classnames from 'classnames'
import {Location} from 'history'
import {Location, Pathname} from 'history'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Pathname type is just string, but I agree with the decision to use Pathname.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, easier to infer the semantic meaning this way. It was previously Path (string) in history@v4.

import React from 'react'
import styled from 'styled-components'
import Box from './Box'
Expand DownExpand Up@@ -54,7 +54,7 @@ function Breadcrumbs({className, children, sx: sxProp}: React.PropsWithChildren<
}

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

Expand Down
4 changes: 2 additions & 2 deletions src/Header.tsx
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
import {Location} from 'history'
import {Location, Pathname} from 'history'
import styled, {css} from 'styled-components'
import {get} from './constants'
import sx, {SxProp} from './sx'
import {ComponentProps} from './utils/types'

type StyledHeaderItemProps = {full?: boolean} & SxProp
type StyledHeaderProps = SxProp
type StyledHeaderLinkProps = {to?: Location} & SxProp
type StyledHeaderLinkProps = {to?: Location | Pathname} & SxProp

const Header = styled.div<StyledHeaderProps>`
z-index: 32;
Expand Down
4 changes: 2 additions & 2 deletions src/SideNav.tsx
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import {Location} from 'history'
import {Location, Pathname} from 'history'

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

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

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

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

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

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

Expand Down