There seems to be a perplexing issue with TS not being able to find the module in my project, while it works perfectly fine in another project. My project : https://github.com/JesusTheHun/react-typescript-boilerplate-big The project I'm referring to for guidance is https://github.com/piotrwitek/react-redux-typescript-realworld-app .
In my project, the ProjectTypes
module is declared in store/types.d.ts
and imported in store/index.ts
, but TypeScript is unable to locate it. Interestingly, in the other project, the same module is declared in store/types.d.ts
and imported in store/index.ts
. It functions smoothly for one project but encounters issues in mine.
Despite using identical versions of TypeScript for both projects, and meticulously comparing configurations multiple times, I am unable to identify any discrepancies. I seem to be overlooking something crucial, but unfortunately, I cannot pinpoint what it may be.
After attempting to use --traceResolution
, I discovered that it utilizes "cache" to resolve the module in the other project, whereas it only searches in node_modules for my project.
Here are snippets from the code :
// tsconfig.json
{
"include": ["src", "typings"],
"exclude": ["src/**/*.spec.*"],
"extends": "./node_modules/react-redux-typescript-scripts/tsconfig.json",
"compilerOptions": {
}
}
The extended tsconfig.json
// ./node_modules/react-redux-typescript-scripts/tsconfig.json
{
// Configuration options listed here ...
}
Module declaration snippet
import { StateType, ActionType } from 'typesafe-actions';
declare module 'ProjectTypes' {
export type Store = StateType<typeof import('./index').default>;
export type RootAction = ActionType<typeof import('./actions').default>;
export type RootState = StateType<ReturnType<typeof import('./reducers').default>>;
}
declare module 'typesafe-actions' {
interface Types {
RootAction: ActionType<typeof import('./root-action').default>;
}
}
Import statement causing trouble
import { RootAction, RootState, Services } from 'ProjectTypes';