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

Transform codebase to typescript #462

Closed
wants to merge 0 commits into from
Closed

Conversation

radek-stary
Copy link

@radek-stary radek-stary commented Apr 17, 2023

See #394.

tsconfig.json Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
jest.config.js Outdated
@@ -2,19 +2,25 @@ module.exports = {
moduleFileExtensions: [
'js',
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor

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:

  1. that does the jsx -> tsx rename on files where the rename was nopt detected
  2. 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.

Copy link
Member

@adamkudrna adamkudrna Apr 26, 2023

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

Copy link
Contributor

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.

@@ -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'),
Copy link
Contributor

Choose a reason for hiding this comment

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

please fix whitespace

Copy link
Member

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?

@@ -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;
Copy link
Contributor

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%)?

@@ -9,4 +9,4 @@ export default {
next: 'Next',
previous: 'Previous',
},
};
} as Record<string, Record<string, string>>;
Copy link
Contributor

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.

Copy link
Contributor

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 😕

Copy link
Member

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

@radek-stary radek-stary force-pushed the transform-typescript branch 3 times, most recently from 33dc915 to 73ea1ac Compare April 26, 2023 11:49
Copy link
Member

@adamkudrna adamkudrna left a 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
}
}
]
}
Copy link
Member

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';
Copy link
Member

Choose a reason for hiding this comment

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

⚠️ Not all colors can be always used. There are multiple "dictionaries" that group colors suitable for certain use case, see RUI docs.

Does it make sense to separate them in TS? (I think it does, but maybe not now.)

Copy link
Contributor

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
Copy link
Member

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',
Copy link
Member

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"
Copy link
Member

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?

{ size: 'large' },
(rootElement: HTMLElement) => expect(rootElement).toHaveClass('isRootSizeLarge'),
],

Copy link
Member

Choose a reason for hiding this comment

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

Needless blank line

Copy link
Member

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"
Copy link
Member

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;
Copy link
Member

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.


export const AlertWithGlobalProps = withGlobalProps(Alert, 'Alert');

export default AlertWithGlobalProps;
Copy link
Member

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

@radek-stary radek-stary force-pushed the transform-typescript branch 5 times, most recently from 516cbc4 to e8cf786 Compare April 28, 2023 02:42
@radek-stary radek-stary changed the title transform codebase to typescript Transform codebase to typescript Apr 28, 2023
@radek-stary radek-stary marked this pull request as draft April 28, 2023 04:42
@radek-stary radek-stary closed this May 1, 2023
@radek-stary radek-stary force-pushed the transform-typescript branch from e8cf786 to 6213b0a Compare May 1, 2023 13:48
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