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

[Refact/Fix] typescript styled components #219

Merged
merged 20 commits into from
Apr 15, 2022

Conversation

kamikazebr
Copy link
Member

@kamikazebr kamikazebr commented Apr 9, 2022

We need re-able typescript to styled-components.

It could avoid errors, typos and acelerate the development, mainly for the new contributors.

Plus we get fast refactors when we need, because the IDE will warn us about if it's broken before we try test it out.

Bugs / typos found

Some bug / typos founded in convertion

  • 1 Dead code, because we silencied the strong types.

Captura de tela 2022-04-09 194227

  • 2 We have 2 components with the same name. FilterWrapperStyled but one have and use isSmallResolution the another not.
    bug2

And more in changed files.

Advantages

  • 1 IDE pop up the correct type and we get the power of use TypeScript
    pros1

  • 2 Refactor are more fast and safe to do.

  • 3 If you dont know how the component works, you dont need read ton the codes, just check the types that accept.

  • 4 Avoid typos, errors and bugs

2 Alternatives to implement

  • 1 adding types direct in generic space - more simple
    Captura de tela 2022-04-09 194504

  • 2 creating interface/type to more complex properties

unknown (1)

Bonus

Like the last image above, we yet can get more strong type using css template string it allow write css code with IDE help and check, if all its right.

@vercel
Copy link

vercel bot commented Apr 9, 2022

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/1hive/quests/Db53565CyF5xsodjw9v8USssV1Kf
✅ Preview: https://quests-git-refact-typescript-styled-components-1hive.vercel.app

@kamikazebr kamikazebr self-assigned this Apr 9, 2022
@vercel vercel bot temporarily deployed to Preview April 10, 2022 00:07 Inactive
@vercel vercel bot temporarily deployed to Preview April 10, 2022 00:27 Inactive
@vercel vercel bot temporarily deployed to Preview April 11, 2022 00:55 Inactive
Base automatically changed from enhance-header-responsivness to main April 11, 2022 05:54
@vercel vercel bot temporarily deployed to Preview April 12, 2022 18:07 Inactive
@vercel vercel bot temporarily deployed to Preview April 12, 2022 18:13 Inactive
@vercel vercel bot temporarily deployed to Preview April 12, 2022 19:19 Inactive
@@ -12,9 +12,8 @@
"@babel/preset-typescript"
],
"plugins": [
["babel-plugin-styled-components", { "displayName": true }],
"@babel/plugin-transform-react-jsx-source",
"@babel/plugin-proposal-class-properties"
Copy link
Member Author

Choose a reason for hiding this comment

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

It exist inside the react-preset

@@ -42,6 +42,7 @@
"react/no-unused-prop-types": "warn",
"jsx-props-no-spreading": "off",
"react/jsx-props-no-spreading": "off",
"react/state-in-constructor": "off",
Copy link
Member Author

Choose a reason for hiding this comment

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

Needed because some preset (i think airbnb) and the ErrorBoundary component dont have constructor to receive the props.

@@ -89,16 +89,16 @@
"@babel/preset-react": "^7.7.4",
"@babel/preset-typescript": "^7.16.7",
"@sentry/webpack-plugin": "^1.15.1",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/react-hooks": "^8.0.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

They fixed the react problem with versions, it was getting react 18

"@types/jest": "^27.4.1",
"@types/lodash-es": "^4.17.5",
Copy link
Member Author

Choose a reason for hiding this comment

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

its the same

Comment on lines +147 to +148
"@types/react": "17.0.44",
"@types/react-dom": "17.0.15"
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed the react types using resolutions

@vercel vercel bot temporarily deployed to Preview April 14, 2022 17:32 Inactive
@vercel vercel bot temporarily deployed to Preview April 14, 2022 20:35 Inactive
@vercel vercel bot temporarily deployed to Preview April 14, 2022 20:44 Inactive
@kamikazebr kamikazebr merged commit e3ed71f into main Apr 15, 2022
@kamikazebr kamikazebr deleted the refact/typescript-styled-components branch April 15, 2022 12:50
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.

None yet

2 participants