tsconfig path aliases stopped to work in phpstorm 2019.1

With previous version i was able to have autocomplete from imported classes, using webpack alias.

After updating to v2019.1, autocomplete stop to work, and phpstorm inspection shows a message saying: "unresolved function or method"...

 

webpack config:

 

resolve: {

alias: {
'@app': path.resolve('./resources/app')
}

 

tsconfig:

"baseUrl": "./app",
"paths": {
"@app/*": ["*"]
}

 

I as able to import like this:

import {ctk} from "@app/services/ctk.service";




And use:

 

ctk.getSomewthing.subscribe()

 

- Now method 'getSomething' is in red color with the message:  'unresolved function or method'

 

 

 

 

10 comments

webpack aliases work fine for me. What language is it - javascript or typescript? Sample project that shows up the issue would be helpful

0

webpackaliases had never worked in TypeScript; paths resolving is based on path mappings in tsconfig.json - and they do work for me:

 

0

I'm doing  path mapping in my tsconfig.json:

"baseUrl": "./app",
"paths": {
"@app/*": ["*"]
}

This was working in PhpStorm-2018.1. After upgrading to current version i got this issues.

 

0

as you can see in screenshot above, similar mappings work fine for me

Please try invalidating caches - does the issue persist?

0

Invalidating cache didn't help. To make it work again i had to downgrade to version 2018.1

0

please share a project I can use to recreate the issue

0

thank you for help. The current project i can't share it, i will build a testing one where i can replicate this and then i will share it with you,

 

Meanwhile i found:

(with v2019.1) Files that use import with aliases under 5th folder level have this problem. BUT for the first levels it works fine.

0

Test project will be appreciated, thank you!

0

Sorry for the delay.

I wasn't unable to figure what was the problem until now. I will provide an example soon.

The problem has to do with angular lazy loading. When you define a route in a module like this:

loadChildren: './dashboard/dashboard.customer.module#DashboardModule'

Any component inside the dashboard.customer.module that imports services or other classes with an alias, will produce the  'unresolved function or method' problem described above.

 

 

 

 

 

 

 

0

Please sign in to leave a comment.