RTK 2.0: Export All Internal Types and Functions #3681
Replies: 3 comments 7 replies
-
Are there any additional import/type errors you're seeing with the current 2.0-beta.1 release? |
Beta Was this translation helpful? Give feedback.
-
If continuing to export additional types on your Publicly Supported APIs is okay, then this idea wouldn't be useful. This idea is to help avoid the increasing amount of APIs you need to maintain the stability and support for (nearly indefinitely). This addresses feedback provided by @phryneas on #3569 (comment) As a bonus, I think it could help with organization within the package itself as well. |
Beta Was this translation helpful? Give feedback.
-
@markerikson I noticed a package called I'd like to add a step in the CI workflow that leverages It'll sure help me catch anything I should/shouldn't be exporting. |
Beta Was this translation helpful? Give feedback.
-
Roadmap
@microsoft/api-extractor
to catch the public exporting of internal resources from Supported Public APIs@reduxjs/toolkit/internal
exportThe Idea
With the move to ESM in version 2.0, I'd like to propose an idea to export all types and functions in RTK. This idea should resolve many (if not, all of) those pesky...
The inferred type of 'X' cannot be named without a reference to '../node_modules/@reduxjs/toolkit/<some path>.ts'. This is likely not portable. A type annotation is necessary.
...that appear everywhere when declarations are enabled in
tsconfig.json
, while still not having to give provide continual support to every type/function export.The advantage of ESM packages is the use of the 'exports" property: bundle outputs separately and define their path. I propose outputting a new
@redux/toolkit/internal
export..
@reduxjs/toolkit
./query
@reduxjs/toolkit/query
./query/react
@reduxjs/toolkit/query/react
./internal
@reduxjs/toolkit/internal
Advantages
In summary, I think this provides the following advantages:
@reduxjs/toolkit/internal
Final Thoughts
This idea is motivated by finding myself in situations that I would be willing to take the unsupported risk of using certain internal types. * BUT MAINLY * because I keep encountering so many TS portability errors when using RTK for a library-type projects.
I already see an
@internal
in the configurations pointed to thesrc
root. It would required some reorganization to put the internal resources into its own sub directory with an index:src/internal/index.ts
.If you read this, thank you for your time. I appreciate it! Very excited for 2.0.
Beta Was this translation helpful? Give feedback.
All reactions