Skip to content

baseUrl & paths not working correctly #2634

Closed

Description

@tmansson

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?

Activity

  1. filipesilva commented on Oct 10, 2016

    @filipesilva
    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.

  2. tmansson commented on Oct 11, 2016

    @tmansson
    Author

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

  3. angular-automatic-lock-bot commented on Sep 6, 2019

    @angular-automatic-lock-bot

    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.

  4. locked and limited conversation to collaborators on Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions