{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/10320","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/10320/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/10320/comments","events_url":"https://api.github.com/repos/angular/angular/issues/10320/events","html_url":"https://github.com/angular/angular/issues/10320","id":167818310,"number":10320,"title":"Importing service from barrel index.ts file got undefined","user":{"login":"ptomaszi","id":19273934,"avatar_url":"https://avatars.githubusercontent.com/u/19273934?v=3","gravatar_id":"","url":"https://api.github.com/users/ptomaszi","html_url":"https://github.com/ptomaszi","followers_url":"https://api.github.com/users/ptomaszi/followers","following_url":"https://api.github.com/users/ptomaszi/following{/other_user}","gists_url":"https://api.github.com/users/ptomaszi/gists{/gist_id}","starred_url":"https://api.github.com/users/ptomaszi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptomaszi/subscriptions","organizations_url":"https://api.github.com/users/ptomaszi/orgs","repos_url":"https://api.github.com/users/ptomaszi/repos","events_url":"https://api.github.com/users/ptomaszi/events{/privacy}","received_events_url":"https://api.github.com/users/ptomaszi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-27T10:08:37Z","updated_at":"2016-07-27T10:25:48Z","closed_at":null,"body":"I have the following app folder structure:\r\n\r\n--app (index.ts)\r\n   --components (index.ts)\r\n      --home (home.component.ts)\r\n      --login (user-info.service.ts, login-details.ts, login.component.ts, login.routes.ts, index.ts)\r\n\r\nThe login \"index.ts\" file exports all services and components:\r\n\r\n```\r\nexport * from './user-info.service';\r\nexport * from './login-guard.service';\r\nexport * from './login.service';\r\nexport * from './login-details';\r\nexport * from './login.component';\r\nexport * from './login.routes';\r\n```\r\nThe components \"index.ts\" file exports all index files from child folders:\r\n\r\n```\r\nexport * from './user-registration/user-registration.component';\r\nexport * from './login/index';\r\nexport * from './welcome/welcome.routes';\r\nexport * from './welcome/welcome.component';\r\nexport * from './home/home.component';\r\n```\r\n\r\nIn my \"Home\" component I am trying to import \"user-info.service\" from the \"Login\" barrel index file:\r\n\r\n```\r\nimport { Component } from '@angular/core';\r\nimport { UserInfoService } from '../index';\r\n\r\n@Component({\r\n    moduleId: module.id,    \r\n    templateUrl: 'home.component.html',\r\n    styleUrls: ['home.component.css']    \r\n})\r\nexport class HomeComponent {\r\n    public userName: string;\r\n    constructor(private userInfo: UserInfoService) {\r\n        this.userName = userInfo.loginDetails.email;\r\n    }\r\n}\r\n```\r\n\r\nI got the following exception:\r\n\r\n> browser_adapter.ts:82 EXCEPTION: Error: Uncaught (in promise): Can't resolve all parameters for HomeComponent: (?)\r\n\r\nWhen I change the import statement to import directly from the \"user-infor.service.ts\" file it works without any issues:\r\n\r\n`import { UserInfoService } from '../login/user-info.service';`\r\n\r\nI am not really sure why there is an issue when I try to import from the \"index.ts\" file.\r\n\r\nMy \"system-config.ts\" file looks like:\r\n\r\n```\r\nvar barrels: string[] = [\r\n  // App specific barrels.\r\n  'app',\r\n  'app/shared',  \r\n    'app/shared/di-core',\r\n    'app/shared/upgrade',\r\n    'app/components',\r\n    'app/components/welcome',\r\n  'app/components/login',\r\n  'app/components/home'\r\n];\r\n\r\nvar cliSystemConfigPackages: any = {};\r\nbarrels.forEach((barrelName: string) => {\r\n  cliSystemConfigPackages[barrelName] = { main: 'index' };\r\n});  \r\n```\r\nAny ideas or suggestions please?"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/235547368","html_url":"https://github.com/angular/angular/issues/10320#issuecomment-235547368","issue_url":"https://api.github.com/repos/angular/angular/issues/10320","id":235547368,"user":{"login":"ptomaszi","id":19273934,"avatar_url":"https://avatars.githubusercontent.com/u/19273934?v=3","gravatar_id":"","url":"https://api.github.com/users/ptomaszi","html_url":"https://github.com/ptomaszi","followers_url":"https://api.github.com/users/ptomaszi/followers","following_url":"https://api.github.com/users/ptomaszi/following{/other_user}","gists_url":"https://api.github.com/users/ptomaszi/gists{/gist_id}","starred_url":"https://api.github.com/users/ptomaszi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptomaszi/subscriptions","organizations_url":"https://api.github.com/users/ptomaszi/orgs","repos_url":"https://api.github.com/users/ptomaszi/repos","events_url":"https://api.github.com/users/ptomaszi/events{/privacy}","received_events_url":"https://api.github.com/users/ptomaszi/received_events","type":"User","site_admin":false},"created_at":"2016-07-27T10:25:48Z","updated_at":"2016-07-27T10:25:48Z","body":"No as my \"UserInfoService\" is registered at the bootstrap level and not per individual component. I only want to have a single instance of the service available for every component in the application."}}
{"actor":{"display_login":"ptomaszi"}}