Visual Studio Code can't resolve angular's tsconfig paths

Multi tool use
up vote
0
down vote
favorite
I'm trying to import some services using barrels and tsconfigs paths
options but I can't get angular and vscode to get along.
If it works for one it doesn't for the other and viceversa...
My situation seems to be pretty simple:
- in
src/app/services
I have a service which is exported in a index.ts - my
src/tsconfig.app.json
is just this:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": ,
"baseUrl": ".",
"paths": {
"services": ["app/services"]
}
},
"exclude": [
"test.ts",
"**/*.spec.ts"
],
}
and my angular app compiles with no issues, but vscode keep giving me errors every time I try to import my service from 'services'
giving me [ts] Cannot find module 'services'.
why?
I'm using typescript 3.1.6 and in vscode settings I have "typescript.tsdk": "C:/Users/myuser/AppData/Roaming/npm/node_modules/typescript/lib"
(I also tried to leave the default setting, no changes)
edit:
if I specify paths
in ./tsconfig.json
starting from src
, vscode is happy but angular is not.
if I specify paths
in both tsconfig.json
and src/tsconfig.app.json
, both vscode and angular are happy, but it seems a too stupid workaround to me...
angular typescript visual-studio-code vscode-settings tsconfig
add a comment |
up vote
0
down vote
favorite
I'm trying to import some services using barrels and tsconfigs paths
options but I can't get angular and vscode to get along.
If it works for one it doesn't for the other and viceversa...
My situation seems to be pretty simple:
- in
src/app/services
I have a service which is exported in a index.ts - my
src/tsconfig.app.json
is just this:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": ,
"baseUrl": ".",
"paths": {
"services": ["app/services"]
}
},
"exclude": [
"test.ts",
"**/*.spec.ts"
],
}
and my angular app compiles with no issues, but vscode keep giving me errors every time I try to import my service from 'services'
giving me [ts] Cannot find module 'services'.
why?
I'm using typescript 3.1.6 and in vscode settings I have "typescript.tsdk": "C:/Users/myuser/AppData/Roaming/npm/node_modules/typescript/lib"
(I also tried to leave the default setting, no changes)
edit:
if I specify paths
in ./tsconfig.json
starting from src
, vscode is happy but angular is not.
if I specify paths
in both tsconfig.json
and src/tsconfig.app.json
, both vscode and angular are happy, but it seems a too stupid workaround to me...
angular typescript visual-studio-code vscode-settings tsconfig
And did you try setting the TSDK to your project instead of the NPM one ?
– trichetriche
Nov 6 at 14:00
yep, no changes... also, I edited my question
– Doc
Nov 6 at 14:07
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to import some services using barrels and tsconfigs paths
options but I can't get angular and vscode to get along.
If it works for one it doesn't for the other and viceversa...
My situation seems to be pretty simple:
- in
src/app/services
I have a service which is exported in a index.ts - my
src/tsconfig.app.json
is just this:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": ,
"baseUrl": ".",
"paths": {
"services": ["app/services"]
}
},
"exclude": [
"test.ts",
"**/*.spec.ts"
],
}
and my angular app compiles with no issues, but vscode keep giving me errors every time I try to import my service from 'services'
giving me [ts] Cannot find module 'services'.
why?
I'm using typescript 3.1.6 and in vscode settings I have "typescript.tsdk": "C:/Users/myuser/AppData/Roaming/npm/node_modules/typescript/lib"
(I also tried to leave the default setting, no changes)
edit:
if I specify paths
in ./tsconfig.json
starting from src
, vscode is happy but angular is not.
if I specify paths
in both tsconfig.json
and src/tsconfig.app.json
, both vscode and angular are happy, but it seems a too stupid workaround to me...
angular typescript visual-studio-code vscode-settings tsconfig
I'm trying to import some services using barrels and tsconfigs paths
options but I can't get angular and vscode to get along.
If it works for one it doesn't for the other and viceversa...
My situation seems to be pretty simple:
- in
src/app/services
I have a service which is exported in a index.ts - my
src/tsconfig.app.json
is just this:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": ,
"baseUrl": ".",
"paths": {
"services": ["app/services"]
}
},
"exclude": [
"test.ts",
"**/*.spec.ts"
],
}
and my angular app compiles with no issues, but vscode keep giving me errors every time I try to import my service from 'services'
giving me [ts] Cannot find module 'services'.
why?
I'm using typescript 3.1.6 and in vscode settings I have "typescript.tsdk": "C:/Users/myuser/AppData/Roaming/npm/node_modules/typescript/lib"
(I also tried to leave the default setting, no changes)
edit:
if I specify paths
in ./tsconfig.json
starting from src
, vscode is happy but angular is not.
if I specify paths
in both tsconfig.json
and src/tsconfig.app.json
, both vscode and angular are happy, but it seems a too stupid workaround to me...
angular typescript visual-studio-code vscode-settings tsconfig
angular typescript visual-studio-code vscode-settings tsconfig
edited Nov 6 at 14:04
asked Nov 6 at 13:52
Doc
1,45642653
1,45642653
And did you try setting the TSDK to your project instead of the NPM one ?
– trichetriche
Nov 6 at 14:00
yep, no changes... also, I edited my question
– Doc
Nov 6 at 14:07
add a comment |
And did you try setting the TSDK to your project instead of the NPM one ?
– trichetriche
Nov 6 at 14:00
yep, no changes... also, I edited my question
– Doc
Nov 6 at 14:07
And did you try setting the TSDK to your project instead of the NPM one ?
– trichetriche
Nov 6 at 14:00
And did you try setting the TSDK to your project instead of the NPM one ?
– trichetriche
Nov 6 at 14:00
yep, no changes... also, I edited my question
– Doc
Nov 6 at 14:07
yep, no changes... also, I edited my question
– Doc
Nov 6 at 14:07
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
I figured it out, even if I'm keep thinking that is all absurd...
VsCode automatically look for a tsconfig.json
file and it doesn't care about tsconfig.app.json
, so paths
needs to be specified in tsconfig.json
.
At the same time, the angular-cli scaffolding specify a baseUrl
parameter in tsconfig.app.json
which overrides the upper one.
The solution is to delete baseUrl
parameter in the tsconfig.app.json
or edit its value to "../"
(As a personal remark, given that vscode is largely used to build angular solutions, I think that there's something that should be revisited in the angular-cli scaffolding or in how vscode looks for tsconfig files)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
I figured it out, even if I'm keep thinking that is all absurd...
VsCode automatically look for a tsconfig.json
file and it doesn't care about tsconfig.app.json
, so paths
needs to be specified in tsconfig.json
.
At the same time, the angular-cli scaffolding specify a baseUrl
parameter in tsconfig.app.json
which overrides the upper one.
The solution is to delete baseUrl
parameter in the tsconfig.app.json
or edit its value to "../"
(As a personal remark, given that vscode is largely used to build angular solutions, I think that there's something that should be revisited in the angular-cli scaffolding or in how vscode looks for tsconfig files)
add a comment |
up vote
0
down vote
accepted
I figured it out, even if I'm keep thinking that is all absurd...
VsCode automatically look for a tsconfig.json
file and it doesn't care about tsconfig.app.json
, so paths
needs to be specified in tsconfig.json
.
At the same time, the angular-cli scaffolding specify a baseUrl
parameter in tsconfig.app.json
which overrides the upper one.
The solution is to delete baseUrl
parameter in the tsconfig.app.json
or edit its value to "../"
(As a personal remark, given that vscode is largely used to build angular solutions, I think that there's something that should be revisited in the angular-cli scaffolding or in how vscode looks for tsconfig files)
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I figured it out, even if I'm keep thinking that is all absurd...
VsCode automatically look for a tsconfig.json
file and it doesn't care about tsconfig.app.json
, so paths
needs to be specified in tsconfig.json
.
At the same time, the angular-cli scaffolding specify a baseUrl
parameter in tsconfig.app.json
which overrides the upper one.
The solution is to delete baseUrl
parameter in the tsconfig.app.json
or edit its value to "../"
(As a personal remark, given that vscode is largely used to build angular solutions, I think that there's something that should be revisited in the angular-cli scaffolding or in how vscode looks for tsconfig files)
I figured it out, even if I'm keep thinking that is all absurd...
VsCode automatically look for a tsconfig.json
file and it doesn't care about tsconfig.app.json
, so paths
needs to be specified in tsconfig.json
.
At the same time, the angular-cli scaffolding specify a baseUrl
parameter in tsconfig.app.json
which overrides the upper one.
The solution is to delete baseUrl
parameter in the tsconfig.app.json
or edit its value to "../"
(As a personal remark, given that vscode is largely used to build angular solutions, I think that there's something that should be revisited in the angular-cli scaffolding or in how vscode looks for tsconfig files)
edited 17 hours ago
answered Nov 6 at 14:23
Doc
1,45642653
1,45642653
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53173306%2fvisual-studio-code-cant-resolve-angulars-tsconfig-paths%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
cdmtb kOIDjb,WxHTM4T,9VcOTPfYALyh,pfYzrOa8Tl u,7ymbGgZlEA
And did you try setting the TSDK to your project instead of the NPM one ?
– trichetriche
Nov 6 at 14:00
yep, no changes... also, I edited my question
– Doc
Nov 6 at 14:07