Skip to content

baseUrl & paths not working correctly #2634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bialad opened this issue Oct 10, 2016 · 3 comments
Closed

baseUrl & paths not working correctly #2634

bialad opened this issue Oct 10, 2016 · 3 comments

Comments

@bialad
Copy link

bialad commented Oct 10, 2016

Please provide us with the following information:

OS?

Windows 10.

Versions.

angular-cli: 1.0.0-beta.17
node: 6.7.0
os: win32 x64

Repro steps.

Updating my app from beta.16 to beta.17, and trying to utilise the new baseUrl & paths configuration in tsconfig.json as follows:

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

When I use

import { Http } from '@angular/http';
import { StorageService } from '@shared/services';

@Injectable()
export class AuthService {
  constructor(private http: Http, private storageService: StorageService) { ... }
}

typescript and webpack compiles and builds without erros, but I get an error in chrome that says

Can't resolve all parameters for AuthService: (Http, ?)

But if I write:

import { Http } from '@angular/http';
import { StorageService } from './storage.service';

@Injectable()
export class AuthService {
  constructor(private http: Http, private storageService: StorageService) { ... }
}

it works.

AuthService and StorageService are in the same folder app/shared/services/ and there's an index.ts with export * from './storage.service'; in it, so this should work right?

Is there anything more I need to add to tsconfig.json or angular-cli.json to get it to work?

@filipesilva
Copy link
Contributor

Same as #1831. It's a circular dependency. Best way to avoid it is to not try to use the barrel file from inside that barrel.

@bialad
Copy link
Author

bialad commented Oct 11, 2016

You're right, don't think I would have found that on my own. Thanks! :)

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants