-
Notifications
You must be signed in to change notification settings - Fork 7
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
Transform codebase to typescript #462
Conversation
jest.config.js
Outdated
@@ -2,19 +2,25 @@ module.exports = { | |||
moduleFileExtensions: [ | |||
'js', |
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.
Do we need to keep the jsx
extension? Do we want to keep it?
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.
If changing here, please also adjust transform
below.
src/docs/_components/Icon/Icon.tsx
Outdated
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.
Apparently git does not detect the jsx
-> tsx
rename as a rename.
According to https://stackoverflow.com/questions/29822823/how-does-git-know-that-file-was-renamed this can happen.
Would it be possible to dissect this PR into two commits:
- that does the
jsx
->tsx
rename on files where the rename was nopt detected - another that does the code change
Then, before merge we would squash these two commits. I can not think of another way how to handle this safely and sanely.
With git rebase
it should not be too much work.
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.
Apparently git does not detect the jsx -> tsx rename as a rename
My feeling is it depends on the amount/nature of changes inside the renamed file. Sometimes it gets it right, sometimes not (see #440).
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.
I think the name of the folder holding this file is wrong.
webpack.config.js
Outdated
@@ -69,7 +74,7 @@ module.exports = (env, argv) => ({ | |||
? '[name].js' | |||
: '[name].development.js', | |||
libraryTarget: 'umd', | |||
path: path.join(__dirname, 'dist'), | |||
path: path.join(__dirname, 'dist'), |
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.
please fix whitespace
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.
Why did ESlint miss that?
webpack.config.js
Outdated
@@ -2,16 +2,16 @@ const path = require('path'); | |||
const StyleLintPlugin = require('stylelint-webpack-plugin'); | |||
const VisualizerPlugin = require('webpack-visualizer-plugin'); | |||
|
|||
const MAX_DEVELOPMENT_OUTPUT_SIZE = 3000000; | |||
const MAX_PRODUCTION_OUTPUT_SIZE = 335000; | |||
const MAX_DEVELOPMENT_OUTPUT_SIZE = 4000000; |
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.
Do we have any ideas why the size increase? Is it really that much (~30%)?
src/lib/translations/en.ts
Outdated
@@ -9,4 +9,4 @@ export default { | |||
next: 'Next', | |||
previous: 'Previous', | |||
}, | |||
}; | |||
} as Record<string, Record<string, string>>; |
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.
I would prefer to create a dedicated interface or type for translation that whitelist that specifies the concrete object keys. That way if anyone needs to provide translations for another language, they can leverage the type system.
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.
For some reason this test fails when run as npm run lib:jest
. However it passes when run as npm run lib:jest
.
The same thing happens in master
, but it does not happen in CI.
I have no idea what is going on 😕
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.
@mbohal Both your commands are identical 🙂.
33dc915
to
73ea1ac
Compare
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.
I'm so curious about the final result, can't wait to finally learn TS 🙂.
- To me it appears ESlint is sleeping instead of doing its job… There are many formating issues lost in translation…
- Please fix the branch name and commit message according to our conventions so the changes make their way to the CHANGELOG (among other reasons 🙂).
.eslintrc
Outdated
} | ||
} | ||
] | ||
} |
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.
Please fix the new line at the end of the file.
definitions.d.ts
Outdated
/** | ||
* [Color variant](/foundation/colors#component-colors) | ||
*/ | ||
declare type Color = 'primary' | 'secondary' | 'selected' | 'success' | 'warning' | 'danger' | 'help' | 'info' | 'note' | 'light' | 'dark'; |
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.
Does it make sense to separate them in TS? (I think it does, but maybe not now.)
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.
Does it make sense to separate them in TS?
Yes, it makes sense to do it now.
definitions.d.ts
Outdated
|
||
declare type PredefinedLabelWidthValues = 'auto' | 'default' | 'limited'; | ||
|
||
// Test types |
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.
Why a different type of comment? I mean //
vs. /* */
.
Secondly, why only some types have comments and some don't?
jest.config.js
Outdated
@@ -2,19 +2,25 @@ module.exports = { | |||
moduleFileExtensions: [ | |||
'js', |
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.
If changing here, please also adjust transform
below.
package.json
Outdated
@@ -33,7 +33,8 @@ | |||
"npm": ">=8.3.0" | |||
}, | |||
"dependencies": { | |||
"normalize.css": "^8.0.1" | |||
"normalize.css": "^8.0.1", | |||
"ts-jest": "^27.1.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.
Isn't it a dev dependency?
tests/propTests/sizePropTest.ts
Outdated
{ size: 'large' }, | ||
(rootElement: HTMLElement) => expect(rootElement).toHaveClass('isRootSizeLarge'), | ||
], | ||
|
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.
Needless blank line
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.
I suppose the propTests_in_javascript
directory is not going to be merged into master
, right?
.eslintrc
Outdated
"airbnb-typescript", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:typescript-sort-keys/recommended", | ||
// "plugin:@typescript-eslint/recommended-requiring-type-checking" |
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.
Is this line going to be used in a next step? If not, I'd delete it.
</div> | ||
); | ||
}; | ||
export default Placeholder; |
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.
There should be a blank line before the default export, I believe.
src/lib/components/Alert/Alert.tsx
Outdated
|
||
export const AlertWithGlobalProps = withGlobalProps(Alert, 'Alert'); | ||
|
||
export default AlertWithGlobalProps; |
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.
Please fix the missing end of line
516cbc4
to
e8cf786
Compare
e8cf786
to
6213b0a
Compare
See #394.