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

TypeScript error when upgrading to react-redux 8.0.0 #1909

Closed
1 task done
atomrc opened this issue Apr 19, 2022 · 7 comments · Fixed by #1910
Closed
1 task done

TypeScript error when upgrading to react-redux 8.0.0 #1909

atomrc opened this issue Apr 19, 2022 · 7 comments · Fixed by #1910

Comments

@atomrc
Copy link

atomrc commented Apr 19, 2022

What version of React, ReactDOM/React Native, Redux, and React Redux are you using?

  • React: 16.14.0
  • ReactDOM/React Native: 16.14.0
  • Redux: 4.2.0
  • React Redux: 8.0.0

What is the current behavior?

When compiling a TypeScript project that has the noImplicitAny config set to true, then react-redux .ts files are typechecked and result in a compilation error

node_modules/react-redux/src/utils/Subscription.ts:95:8 - error TS7011: Function expression, which lacks return-type annotation, implicitly has an 'any[]' return type.

95   get: () => [],
          ~~~~~~~~


Found 1 error in node_modules/react-redux/src/utils/Subscription.ts:95

I believe the ts files should be stripped from the final bundle that is uploaded to npm in order to avoid such ts config mismatch.

What is the expected behavior?

There shouldn't be any compilation error.

Which browser and OS are affected by this issue?

N/A

Did this work in previous versions of React Redux?

  • Yes
@Dammmien
Copy link

Yep I confirm, I have the same compiling error on my side

@phryneas
Copy link
Member

All the redux-libraries are shipping with the source code - RTK is also already shipping since 1.0 with TypeScript.
You should not really have your bundler check files in your node_modules folder (TypeScript will per default only import .d.ts files from node_modules, not .ts ones unless you explicitly reference them) - did you maybe just include a wrong file?

@vicrep
Copy link
Contributor

vicrep commented Apr 19, 2022

I'm encountering the same issue and do not think this is a TSC misconfiguration or bad-import on the consumer's side, and the error occurs even when explicitly ignoring node modules.

I ran --traceResolution on TSC and that helped me narrow down what I think the issue is:

import type { Subscription } from '../src/utils/Subscription'
re-exports Subscription directly from src (as opposed to relative), which means that the following is then emitted as such in exports.d.ts

import type { Subscription } from '../src/utils/Subscription';

Which is why this error is occurring, as confirmed by trace resolver:

======== Resolving module '../src/utils/Subscription' from '[root]/node_modules/react-redux/es/exports.d.ts'. ========
Explicitly specified module resolution kind: 'NodeJs'.
Loading module as file / folder, candidate module location '[root]/node_modules/react-redux/src/utils/Subscription', target file type 'TypeScript'.
File '[root]/node_modules/react-redux/src/utils/Subscription.ts' exist - use it as a name resolution result.

@vicrep
Copy link
Contributor

vicrep commented Apr 19, 2022

PR to fix here: #1910

@markerikson
Copy link
Contributor

Live in https://github.com/reduxjs/react-redux/releases/tag/v8.0.1 .

@atomrc
Copy link
Author

atomrc commented Apr 20, 2022

Thanks guys for your reactivity 🙏

@Dammmien
Copy link

That was fast 🚀 !!
Thanks 🙏🏻

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 a pull request may close this issue.

5 participants