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

Move to Typescript #36

Merged
merged 1 commit into from
Jan 29, 2019
Merged

Move to Typescript #36

merged 1 commit into from
Jan 29, 2019

Conversation

denieler
Copy link
Collaborator

PICAS-39

Description

This PR is about moving Picasso to Typescript. I want you guys to review the changes has been made and discuss them. The most important once I would like to talk:

  • Plan of the components migration to *.tsx
  • eslint doesn't really make sense for TS, I faced already few problems with it: PropTypes validation, matching Default prop types to PropTypes and, more important, TS types imports from *.d.ts which is not supported by eslint. So as a proposition - having tslint (https://github.com/palantir/tslint) and keep using eslint until we move 100% to TS

@denieler denieler requested a review from a team January 24, 2019 17:32
@bytasv
Copy link
Contributor

bytasv commented Jan 25, 2019

Talking about linting - are there alternatives for standard/prettier, react and other eslint presets in tslint?
Also can't eslint work with TS code?

@denieler
Copy link
Collaborator Author

@bytasv it looks like there are react-related tslint rules: https://github.com/palantir/tslint-react
but as for me they look worse, than what we have now for eslint react.

For eslint there is existing a parser for TS code https://github.com/eslint/typescript-eslint-parser , but after I tried it, it looks like, it was complaining about imported type from MaterialUI. Something like no used import, but I will double-check.

@bytasv
Copy link
Contributor

bytasv commented Jan 25, 2019

Ok, so apparently the obvious way is to stick with ESlint: bradzacher/eslint-plugin-typescript#290

Here is official statement from TS team: microsoft/TypeScript#29288 so we should just take that into consideration, drop TS lint for now I guess and see what can we do to use ESlint

@denieler
Copy link
Collaborator Author

@bytasv yeah, this microsoft/TypeScript#29288 makes a lot of sense 👍 thanks for finding this!

@denieler denieler force-pushed the picas-39-move-to-typescript branch from 1d3dcb5 to 6833c07 Compare January 25, 2019 12:18
@denieler denieler force-pushed the picas-39-move-to-typescript branch from 8efe9bf to 423d9b5 Compare January 25, 2019 13:47
components/Label/test.tsx Outdated Show resolved Hide resolved
components/Label/Label.tsx Outdated Show resolved Hide resolved
classes: {},
label: undefined,
onDelete: undefined,
variant: undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably shouldn't be undefined and it should have some default variant

Copy link
Collaborator Author

@denieler denieler Jan 29, 2019

Choose a reason for hiding this comment

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

we can use default for example, but this variant is our variant which controls the root class which we set for Chip component. But I think it just adds complexity if we specify default instead of just checking for undefined:

const rootClass = variant ? classes[variant] : ''

wdyt @MilosMosovsky ?

components/Label/Label.tsx Outdated Show resolved Hide resolved
components/Label/Label.tsx Show resolved Hide resolved
components/Label/Label.tsx Show resolved Hide resolved
components/Label/Label.tsx Outdated Show resolved Hide resolved
components/Label/Label.tsx Outdated Show resolved Hide resolved
components/Label/Label.tsx Outdated Show resolved Hide resolved
components/Label/Label.tsx Show resolved Hide resolved
components/Label/styles.ts Show resolved Hide resolved
components/Label/Label.tsx Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
"dependencies": {
"@material-ui/core": "^3.6.0",
"@material-ui/core": "3.6.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

important to fix this version, because snapshot tests are failing with updating MUI core. Maybe we can use Greenkeeper or something like that to keep us updated?

@@ -68,7 +80,7 @@
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-react": "^7.11.1",
"eslint-plugin-react": "7.11.1",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Important to fix it, with the new version a lot of new linting problems are appearing. We should update it, but in the other PR

package.json Outdated Show resolved Hide resolved
tsconfig.json Show resolved Hide resolved
bin/build Outdated Show resolved Hide resolved
@denieler denieler force-pushed the picas-39-move-to-typescript branch from 6f9bbad to d25c109 Compare January 29, 2019 11:23
Add config, packages and ts linter

Fix import of React and PropTypes

Fix color import

Remove noEmit config from ts config

Fix unit tests with correct import of color

Support ES6 modules and babel imports in TS

This information was really helpful - https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability

Move Label component to tsx

Fix usage of eslint for Typescript

Enable linting for ts files

Move styles, test files to TS

Update component generator to use TS

Fix default imports for react and prop-types packages

Remove tslint config

Cleanup tsconfig

Fix the issue with linting of imported types for typescript

Remove some classes type casting for Label

Remove webpack and replace with tsc cli

Add 2 configurations for tsc: ES6 and ES2015

Return ts-loader for storybook

Fix version of material-ui core

Fix linting

Simplify classnames for Label

Move default props to the bottom of the component

Fix build script with using Typescript to compile and remove all babel dependencies

Add skiplibcheck to tsconfig

Leave only 1 tsconfig, build only ES6/ES2015 version
@denieler denieler force-pushed the picas-39-move-to-typescript branch from 35d89af to 310dd45 Compare January 29, 2019 11:30
@@ -39,14 +39,14 @@ chapter.addSection('Flat', null, () => (
))

chapter.addSection('Statuses', 'Use these to communicate status.', () => (
<React.Fragment>
<>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do all IDEs support it properly? Or at least the ones that we use?

I use Webstorm

cc @MilosMosovsky

Copy link
Contributor

@bytasv bytasv left a comment

Choose a reason for hiding this comment

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

Looking forward ✅

@denieler denieler merged commit ea6bbc8 into master Jan 29, 2019
@denieler denieler deleted the picas-39-move-to-typescript branch January 29, 2019 11:46
@MilosMosovsky MilosMosovsky added the Chore Everything not related to a new features label Jan 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Chore Everything not related to a new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants