-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/1hive/quests/Db53565CyF5xsodjw9v8USssV1Kf |
packages/react-app/src/components/field-input/date-field-input.tsx
Outdated
Show resolved
Hide resolved
packages/react-app/src/components/utils/transaction-progress-component.tsx
Outdated
Show resolved
Hide resolved
@@ -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" |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its the same
"@types/react": "17.0.44", | ||
"@types/react-dom": "17.0.15" |
There was a problem hiding this comment.
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
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
FilterWrapperStyled
but one have and useisSmallResolution
the another not.And more in changed files.
Advantages
1 IDE pop up the correct type and we get the power of use TypeScript
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
2 creating interface/type to more complex properties
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.