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

Proposal: Migrating progressively to Typescript #3137

Open
hikerpig opened this issue Jul 21, 2019 · 3 comments
Open

Proposal: Migrating progressively to Typescript #3137

hikerpig opened this issue Jul 21, 2019 · 3 comments
Labels
discussion 💬 Issue concerns a discussion.

Comments

@hikerpig
Copy link
Contributor

hikerpig commented Jul 21, 2019

Typescript is powerful, expressive, and very good for collaborative projects. Community support and ecosystem are good for React projects.

Adding it to this codebase, may reduce typos and parameter type errors. New contributors will be a little more relaxed to modify existed code.

I assume there can be some phases for this approach.

Phase 1

Almost painless.

  1. Add a tsconfig.json with allowJs: true and some other compilerOptions to avoid countless strict errors.
  2. Install several @types/* packages. If you're using VSCode, IntelliSense will work pretty good already.

Phase 2

Do some filename converting, from js->ts.

  1. May need to upgrade webpack toolchain to use the latest ts-loader. Or upgrade to [babel@7].(https://devblogs.microsoft.com/typescript/typescript-and-babel-7/) for compiling ts modules.
  2. Install some packages to make sure ava and jest can load ts modules.

Phase 3

Rewrite react components, from js->tsx, will get a lot of errors at first, but anything typed will always make future maintainance a little bit easier. And I assume there may already be some useful codemods or transformers to automate this process.

Rewriting(since phrase 2) is not mandatory, and even after it starts, we can still keep a mixed codebase of js/ts, and recommend to write new code in ts/tsx.

@Flexo013 Flexo013 added the discussion 💬 Issue concerns a discussion. label Jul 21, 2019
@amedora
Copy link
Contributor

amedora commented Jul 22, 2019

looks promising. but,

  • the devs had mentioned about "new version" of this app and they are working on it, so it will be written by TypeScript already I think.
  • As a "Phase 0", that should be also worth to do to cleanup duplicated/abandoned issues/PRs and deadcode in the source tree.

just my two cents.

@Flexo013
Copy link
Contributor

Flexo013 commented Jul 22, 2019

For that second point: we are working on cleaning up all the issues over the next couple weeks. If you know of any issues/PRs that can be closed, then feel free to leave a comment on them. I will then mark and close them accordingly.

@hikerpig
Copy link
Contributor Author

Oh I've just found the repo for renewal version boost.Completely rewritten in Typescript and has some big architectural changes. But it seems to be at an early prototype stage, and development is kind of held up, all the best wishes with Rokt33r 🍺 .

Back to this issue, since this repo may still exist for a long time, I think phase 1 may be worth a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion 💬 Issue concerns a discussion.
Projects
None yet
Development

No branches or pull requests

3 participants