A follow up on #2485. When importing anything from @reduxjs/toolkit@2.0.0-alpha.2, typescript cannot resolve types when tsconfig.json's moduleResolution is set to node16 or nodenext.
I found that adding the extension .js to the declaration imports resolved the issue. For example....
In my file: ./node_modules/@reduxjs/toolkit/dist/index.d.ts
export { createSlice, } from './createSlice'; -> export { createSlice, } from './createSlice.js';
Two suggestions for a fix: First, maybe the easiest, is add a post build script to add the extensions to the output. Or second, a search and replace to add the extensions to the all the relevant source files. Want to get some thoughts on a direction before attempting a PR. Maybe there's a better way.
I tried looking to see if typescript can just add them while compiling... but didn't find anything that could.
A follow up on #2485. When importing anything from
@reduxjs/toolkit@2.0.0-alpha.2, typescript cannot resolve types whentsconfig.json'smoduleResolutionis set tonode16ornodenext.I found that adding the extension
.jsto the declaration imports resolved the issue. For example....In my file:
./node_modules/@reduxjs/toolkit/dist/index.d.tsexport { createSlice, } from './createSlice';->export { createSlice, } from './createSlice.js';Two suggestions for a fix: First, maybe the easiest, is add a post build script to add the extensions to the output. Or second, a search and replace to add the extensions to the all the relevant source files. Want to get some thoughts on a direction before attempting a PR. Maybe there's a better way.
I tried looking to see if typescript can just add them while compiling... but didn't find anything that could.