TS2307: Cannot find module 'actions' or its corresponding type declarations

In my project I have an actions file which I would like to use:

./src/app/actions/auth.actions.ts
```ts
export class Login {
// ...
}
```

Then in the components I would like to use this I want to shorten the import file path from `import {Login} from '../../../../app/actions';` to `import {Login} from 'actions';`

To do that first I'm creating a barrel file:

./src/app/actions/index.ts
```ts
export * from './auth.actions';
```

Then I'm changing the tsconfig.json file to contain the file in the paths option:

```json
{
"compilerOptions": {
"paths": {
"actions": [
"src/app/actions"
]
},
}
```
Now everything seems to be fine, as I'm seeing the following info box in the component I'm using the Login action:


But once I replace it with 'actions' I get the following error:


But it seems to be working. I'm just having this error. Is there something I can do to remove this error?

 

0

Ah, that must be it. My project has a ./be and ./fe folder. Both have a tsconfig file. When I set "Languages & Frameworks > Typescript >" to "~/fe/node_modules/typescript" it works. 

Thank you for verifying!

2

works fine for me using similar setup

how many tsconfig.*.json files do you have in your project?

1

Hi there, I have this issue too since updating to Webstorm to 2021.1. I am using nx.dev with angular 11 and there are several libraries with multiple tsconfig.*.ts files. Anyway, these tsconfig files extends the tsconfig.base.json on root level, where all paths are defined. Are there any suggestions how to solve this?

0

请先登录再写评论。