The problem
Recently I've added Flow to some of the files (not many) but it looks like TypeScript is more favourable now among React developers. Also full codebase conversion would help us find bugs.
Proposed solution
Steps to do it, all can be done one by one as separate pull requests:
typescript as a dependenceytsconfig.json@babel/preset-typescript to Babel config (babel.config.js)@typescript-eslint/parser and @typescript-eslint/eslint-plugin to ESLint config (.eslintrc)@flow comment and replace types inside flow-types with @types/* modules.How I think it should work:
import React from 'react', instead of import * as React from 'react'.Use Tâmia as an example: look at .babelrc, tsconfig.json and package.json.
Can we use react-javascript-to-typescript-transform for mass conversion? Not really: it needs too many manual changes after and removes all formatting including empty lines.
Do you want to use TS only as a type checker?
Yup, I'd like to keep Babel setup as is for now.
I would be happy to help :)
@goku321 That would be great! I've updated he issue with some more details. Let me know if you have any more questions.
@sapegin Maybe flow-to-ts can help a bit in this migration. I can try it out and see how it goes 😄
I can help too. I have experience with typescript and react. Tell me how can I start.
@kakadiadarpan I've tried react-javascript-to-typescript-transform and it wasn't very useful, so would be great if you can try flow-to-ts to compare ;-)
@nathanredblur That's awesome! I've added a list of steps (unless I'm missing anything) for the conversion — no need to do everything at once though ;-)
@sapegin I love to contribute, Where I can start ?
@tanvirraj That's awesome! I've added a list of steps (unless I'm missing anything) for the conversion — no need to do everything at once though ;-)
@sapegin I have been working with TypeScript + React for about a year in my company.. Would be happy to help..
I also happen to know (almost) the internals of this project as I was going through the code to add our own UI to the style guide.
@pavandv This is great!
For everyone: please write a comment if you're working on a particular task, so we won't do the same thing several times.
@sapegin Could you add me as well?
@MaxFlower Sure! No need to ask permission ;-)
@sapegin I'm working on setting up the Typescript Config.
@sapegin Created PR #1461 for setting up typescript configuration.
@sapegin, I believe you can now safely check the eslint and travis boxes.
Looked too fast once again... Sorry, my mistake, the only thing that was added was eslint plugin as a dependency without implementing it.
I am on it. Pull Request coming ;)
After a few hours dabbling with the eslint set-up, I have a better view of where we are.
I have a few questions regarding the current implementation.
jsconfig.json and a tsconfig.json I believe we should merge them."allowJs": true forces type checking on every js file, including the ones with flow typings. This will break a lot of files. I must add that the flag is not necessary if we start converting the leaves first and follow the dependency tree.To present my findings, I have created a new Pull Request as draft. Please tell me what you think.
https://github.com/styleguidist/react-styleguidist/pull/1463
Replace existing Flow types with TS: update files with @flow comment and replace types inside flow-types with @types/* modules.
I'm working on this.
@elevatebart Awesome, thanks! Let's continue the discussion in the PR.
:tada: This issue has been resolved in version 10.3.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Most helpful comment
I'm working on this.