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

Automatically install @types/react-redux as a dependency #1699

Merged
merged 2 commits into from Mar 23, 2021

Conversation

markerikson
Copy link
Contributor

This PR:

  • Adds a hard dependency on @types/react-redux, so that any user who installs the main lib automatically gets the types.

This is a trick I saw from Tanner Linsley and Kent C Dodds, and should resolve cases where users forgot to install the typedefs as well. Given that we're not rewriting in TS until we work on a v8 release, and we aren't planning to bring the typedefs over here any time soon, we might as well make sure they're available all the time.

Also, I tweaked the Prettier config to ignore line endings, because suddenly ESLint claimed that every single line of code in my local environment had the wrong line endings :(

@github-actions
Copy link

Size Change: 0 B

Total Size: 26.5 kB

ℹ️ View Unchanged
Filename Size Change
dist/react-redux.js 21.3 kB 0 B
dist/react-redux.min.js 5.22 kB 0 B

compressed-size-action

@netlify
Copy link

netlify bot commented Mar 23, 2021

Deploy preview for react-redux-docs ready!

Built with commit 82b2d69

https://deploy-preview-1699--react-redux-docs.netlify.app

@markerikson markerikson merged commit da22052 into master Mar 23, 2021
@markerikson markerikson deleted the feature/add-types branch March 23, 2021 00:13
@MBelniak
Copy link

@markerikson Why was it added to "dependencies" instead of "devDependencies"? Types are needed only for development. In the product I work on we have a tool that treats "dependencies" as something that potentially could go into the final bundle and it reports @types/react-redux, which of course will not be included in the bundle :/

@timdorr
Copy link
Member

timdorr commented Aug 12, 2021

@MBelniak Please read the post above by Mark. We're favoring developer experience for those types. In 8.0, we'll be written directly in TS and will have types embedded in the package.

@MBelniak
Copy link

@timdorr devDependencies are installed as well. Anyway, I've just noticed that this was fixed here: https://github.com/reduxjs/react-redux/pull/1766/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519 :) Sorry for disturbing, it will be all fine in the next release :D

@markerikson
Copy link
Contributor Author

markerikson commented Aug 12, 2021

@MBelniak :

devDependencies are installed as well

No, they're not, and that's exactly the point.

Look at our package.json file for v7.2.4:

https://github.com/reduxjs/react-redux/blob/v7.2.4/package.json#L57-L97

It includes Babel, Jest, ESLint, and many more.

I can assure you that when you npm i react-redux, none of those get installed. Package managers do not install devDependencies when you install a library. They install just dependencies (and in the case of NPM 7, peerDependencies as well, although that's a separate topic).

So, the whole reason we added @types/react-redux to dependencies is to ensure that when our users npm i react-redux, they automatically get the types installed as well because many of our users were getting stuck and not realizing those needed to also be installed.

@MBelniak
Copy link

@markerikson OK, this is simply my misunderstanding. What I meant is that when you work on react-redux and run npm install or yarn you'll get devDependencies installed. But, here we talk about the case of installing react-redux and of course devDependencies won't be installed then. You're completely right, thanks for explaining.

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.

None yet

3 participants