-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Support for Typescript Node16 Module Resolution (RTK-Query & RTK-Query/React) #2485
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
Comments
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 |
Yep, redoing the exports / entry points declarations is planned for RTK 2.0, whenever we finally manage to get around to that (hopefully not too long after 1.9 comes out)... but I refuse to even think about touching any of that stuff until we're actually working on 2.0 itself. Too much risk of breaking things. |
It is indeed possible to import createApi from import { createApi } from '@reduxjs/toolkit/dist/query/react'; However, even in this case, it is quite difficult to use RTK Query in a situation where the import { CreateApi } from '@reduxjs/toolkit/query'; So, at this time, I don't think RTK Query can be used in projects where |
You can probably just do declare module '@reduxjs/toolkit/dist/query/react' {
export * from '@reduxjs/toolkit/query'
} somewhere in your app. This seems to be another weird edge case though - normally, importing from |
@phryneas declare module '@reduxjs/toolkit/query/react' {
export * from '@reduxjs/toolkit/dist/query/react';
}
declare module '@reduxjs/toolkit/query' {
export * from '@reduxjs/toolkit/dist/query';
} |
This should hopefully be fixed in https://github.com/reduxjs/redux-toolkit/releases/tag/v2.0.0-alpha.1 . Please try that out and let us know if you see any issues! |
Hey 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 andnode16
set, the two components fail to resovle.It seems Node16 focuses more on the
exports
field of the rootpackage.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 topackage.json
:(It seems types are automatically inferred from those paths)
Thanks all for the awesome library!
The text was updated successfully, but these errors were encountered: