Support for Typescript Node16 Module Resolution (RTK-Query & RTK-Query/React)
See original GitHub issueHey RTK Team,
It seems that using Typescript’s Node16 module resolution is incompatible with separate package.json
files (which is how RTK does the optional query addon, and that query addon’s React component). With the current setup and node16
set, the two components fail to resovle.
It seems Node16 focuses more on the exports
field of the root package.json
, and while I’d submit a PR if I was more familiar with the inner-workings of this repo (and with module resolution as a whole) and more confident that this would not break things, I was able to fix the problem by adding the following to package.json
:
"exports": {
"./query/react": "./dist/query/react/index.js",
"./query": "./dist/query/index.js",
".": "./dist/index.js"
},
(It seems types are automatically inferred from those paths)
Thanks all for the awesome library!
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Usage With TypeScript - Redux Toolkit
This page provides details for using APIs included in RTK Query with TypeScript and how to type them correctly. info. We strongly recommend ......
Read more >Creating React Apps With Redux Toolkit and RTK Query - Toptal
RTK Query is an advanced data-fetching and client-side caching tool. ... Create React App (CRA) template for use with TypeScript and Redux:
Read more >Undefined Error when Fetching API using RTK Query React ...
I keep getting this same error of undefined data for multiple components in my data, it was working fine but for some reason...
Read more >Experimenting with NgRx Store and RTK Query
Developer experience focused and built with TypeScript. RTK Query is also framework-agnostic, which means it can integrate into any framework.
Read more >@reduxjs/toolkit - npm
Redux Toolkit is available as a package on NPM for use with a module bundler or in a Node application: # NPM npm...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This would unfortunately be a breaking change for most other environments - so we will not be able to do that before we release a new major version.
In the meantime, the best you can do is import from
dist
if nothing else works.@phryneas Thank you very much. I solved the problem by declaring module
@reduxjs/toolkit/query/react
and@reduxjs/toolkit/query
.