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

Migrate utils to TypeScript #1055

Merged
merged 6 commits into from
Feb 19, 2021
Merged

Migrate utils to TypeScript #1055

merged 6 commits into from
Feb 19, 2021

Conversation

VanAnderson
Copy link
Contributor

This PR migrates the utils folder to TypeScript as part of the TypeScript refactor.

@changeset-bot
Copy link

changeset-bot bot commented Feb 18, 2021

🦋 Changeset detected

Latest commit: b7904f6

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

This PR includes changesets to release 1 package
Name Type
@primer/components 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

@vercel
Copy link

vercel bot commented Feb 18, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/primer/primer-components/j45rqy8iz
✅ Preview: https://primer-components-git-vananderson-utils-ts-migration.primer.vercel.app

@vercel vercel bot temporarily deployed to Preview February 18, 2021 20:29 Inactive
@VanAnderson VanAnderson mentioned this pull request Feb 18, 2021
53 tasks
@@ -1,16 +1,17 @@
/* eslint-disable no-console */
import {useRef, useCallback} from 'react'
declare var __DEV__: boolean
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a better place for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure. I think this is fine for now 👍

@@ -96,7 +96,7 @@ export function renderStyles(node: React.ReactElement): any {
return getComputedStyles(className)
}

export function getComputedStyles(className: string): Record<string, string> {
export function getComputedStyles(className: string): Record<string, string | Record<string, string>> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feels weird, but was required to make L80 of src/utils/test-matchers.tsx play nice. My understanding of Record<string, string> is that is types and object that maps strings to strings - but it seems that sometimes this will map strings to object groupings that are themselves Record<string, string>, as in the case of the media query key invoked on L80.

Though, I might be misunderstanding this 😅

Comment on lines 203 to 205
Component: React.FunctionComponent<any>
systemPropArray: any[]
toRender?: () => React.ReactElement
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think my linter did this and some of the other changes 🤔

@VanAnderson
Copy link
Contributor Author

getting an error for [dist:types] src/utils/test-matchers.tsx(3,36): error TS7016: Could not find a declaration file for module 'jest-styled-components/serializer'.

I haven't made a declaration file for a non-typescript package yet, looking into a tutorial on how to do this...

@vercel vercel bot temporarily deployed to Preview February 19, 2021 16:24 Inactive
@VanAnderson VanAnderson marked this pull request as ready for review February 19, 2021 16:41
@vercel vercel bot temporarily deployed to Preview February 19, 2021 19:48 Inactive
@vercel vercel bot temporarily deployed to Preview February 19, 2021 19:59 Inactive
Copy link
Contributor

@colebemis colebemis left a comment

Choose a reason for hiding this comment

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

Nice 🎉

src/utils/testing.tsx Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview February 19, 2021 20:10 Inactive
@vercel vercel bot temporarily deployed to Preview February 19, 2021 20:15 Inactive
@colebemis colebemis merged commit edca2de into main Feb 19, 2021
@colebemis colebemis deleted the VanAnderson/utils-ts-migration branch February 19, 2021 20:18
@github-actions github-actions bot mentioned this pull request Feb 19, 2021
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.

2 participants