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

scaffolding for typescript #3504

Merged
merged 5 commits into from
Aug 15, 2019

Conversation

cellog
Copy link
Contributor

@cellog cellog commented Aug 14, 2019

This PR sets up the project to use typescript. It does not yet change any of the actual functionality.

It adds:

  1. @babel/typescript for compiling typescript to js using babel
  2. @typescript-eslint and needed sub-packages for linting typescript
  3. disables no-unused-vars in favor of @typescript-eslint/no-unused-vars, and adds a new strict rule exception - any variable whose name starts with '_' can be ignored as unused
  4. tsconfig.json which controls the type validation one will see in VSCode, and the result of explicitly running tsc
  5. a new check-types script that is added to prepare to check types prior to compilation

Once this is merged, the actual work of typescript conversion may commence

@netlify
Copy link

netlify bot commented Aug 14, 2019

Deploy preview for redux-docs ready!

Built with commit 1b1078c

https://deploy-preview-3504--redux-docs.netlify.com

@timdorr
Copy link
Member

timdorr commented Aug 14, 2019

Looks like eslint-plugin-import got dropped from the lockfile somehow. Try another npm install and that should fix the CI failure.

@JustFly1984
Copy link

Guys we are using tsdx to build our library at @react-google-maps/api and it prove to be reliable and produces very small bundle

@markerikson
Copy link
Contributor

@JustFly1984 : I've looked at tsdx a bit, and agree it seems cool. That said, we've got an existing build setup, and I'd think it'll be easier to integrate TS into what we've got now (especially given our use of Babel) then it would be to switch build setups entirely.

@JustFly1984
Copy link

Btw you don't need eslint-plugin-import for typescript, more than that - it just doesn't support TS

@markerikson markerikson changed the base branch from master to ts-conversion August 15, 2019 00:08
@markerikson
Copy link
Contributor

I just created a new ts-conversion branch and updated the PR to merge into that instead, so we can play around there without disturbing master.

@cellog
Copy link
Contributor Author

cellog commented Aug 15, 2019

Btw you don't need eslint-plugin-import for typescript, more than that - it just doesn't support TS

The PR addresses this issue. If eslint-plugin-import is removed, the build fails. It is part of the react-app preset. In .eslintrc, we disable it with:

    'no-unused-vars': 'off',

and then replace it with the typescript version here:

    '@typescript-eslint/no-unused-vars': [
      'error',
      {
        vars: 'all',
        args: 'after-used',
        ignoreRestSiblings: true,
        argsIgnorePattern: '^_' // ignore unused variables whose name is '_'
      }
    ]

I spent many long hours in a past project trying to figure this out :). If you have a better solution, let's make it happen!

@cellog
Copy link
Contributor Author

cellog commented Aug 15, 2019

ah - I did not look at .travis.yml, I'll fix the linting errors in examples and push that later, then this should be good to go

@cellog
Copy link
Contributor Author

cellog commented Aug 15, 2019

OK, so feedback needed here - the todos-flow example flips out because it is in flow, and not ts. Do we need to lint this example? If so, we will need to add some special case linting that excludes .ts and does flow linting.

For now, I'm adding it to .eslintignore so we can make progress.

@timdorr
Copy link
Member

timdorr commented Aug 15, 2019

I'm happy with just getting rid of that example. I really don't see it adding much value to Redux. It's for Flow users, not Redux users.

@timdorr timdorr merged commit 76d1f98 into reduxjs:ts-conversion Aug 15, 2019
@JustFly1984
Copy link

Well, actually you don’t need create-React-app preset either, you can use eslint-plugin-React, eslint-plugin-React-hooks, eslint-plugin-React-perf and that will be enough.

@cellog cellog deleted the cellog-3500-typescript branch August 15, 2019 21:46
webMasterMrBin pushed a commit to webMasterMrBin/redux that referenced this pull request Aug 21, 2021
* scaffolding for typescript

* add jest types so tests will compile

* remove rollup-plugin-typescript2, probably don't need it

* add missing eslint-import

* fix linting errors


Former-commit-id: 80cb6b8
Former-commit-id: c81ec47
webMasterMrBin pushed a commit to webMasterMrBin/redux that referenced this pull request Aug 21, 2021
* scaffolding for typescript

* add jest types so tests will compile

* remove rollup-plugin-typescript2, probably don't need it

* add missing eslint-import

* fix linting errors


Former-commit-id: 80cb6b8
Former-commit-id: c81ec47
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.

4 participants