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

Conversation

rezrah
Copy link
Contributor

@rezrah rezrah commented Jan 13, 2022

There is a TypeScript error occurring on all components that use the Location definitions from history. This was introduced recently to replace LocationDescriptor, which was recently deprecated as of history@v5.

Error noticed during a smoke test for release candidate on memex:
Screenshot 2022-01-13 at 13 42 32

Solution:
The correct type definition should be a union of Location and string to restore parity with LocationDescriptor. I've used Pathname instead, so it's easier to reason around why string is valid here.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@rezrah rezrah requested review from a team and jfuchs January 13, 2022 13:47
@changeset-bot
Copy link

changeset-bot bot commented Jan 13, 2022

🦋 Changeset detected

Latest commit: a86dffa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rezrah rezrah temporarily deployed to visual-testing January 13, 2022 13:47 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Jan 13, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 61.25 KB (0%)
dist/browser.umd.js 61.63 KB (0%)

@@ -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.

Copy link
Member

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

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

ship it!

@rezrah rezrah merged commit 6a8472b into main Jan 13, 2022
@rezrah rezrah deleted the fix/pathname-types-using-location branch January 13, 2022 14:16
@primer-css primer-css mentioned this pull request Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants