Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: restore string (pathname) in union type for previous LocationDescriptor #1791

Merged
merged 2 commits into from
Jan 13, 2022
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 number Diff line number Diff 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 number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classnames from 'classnames'
import {Location} from 'history'
import {Location, Pathname} from 'history'
Copy link
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
Contributor Author

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 Down Expand 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 number Diff line number Diff 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 number Diff line number Diff 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 Down Expand 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 number Diff line number Diff 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 Down Expand 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 number Diff line number Diff 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 Down Expand 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 number Diff line number Diff 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 Down Expand 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