{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/15223","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/15223/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/15223/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/15223/events","html_url":"https://github.com/Microsoft/TypeScript/issues/15223","id":222190252,"number":15223,"title":"Auto-import quickfix : wrong strategy for import paths","user":{"login":"cyrilletuzi","id":555867,"avatar_url":"https://avatars1.githubusercontent.com/u/555867?v=3","gravatar_id":"","url":"https://api.github.com/users/cyrilletuzi","html_url":"https://github.com/cyrilletuzi","followers_url":"https://api.github.com/users/cyrilletuzi/followers","following_url":"https://api.github.com/users/cyrilletuzi/following{/other_user}","gists_url":"https://api.github.com/users/cyrilletuzi/gists{/gist_id}","starred_url":"https://api.github.com/users/cyrilletuzi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyrilletuzi/subscriptions","organizations_url":"https://api.github.com/users/cyrilletuzi/orgs","repos_url":"https://api.github.com/users/cyrilletuzi/repos","events_url":"https://api.github.com/users/cyrilletuzi/events{/privacy}","received_events_url":"https://api.github.com/users/cyrilletuzi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-04-17T18:12:34Z","updated_at":"2017-04-18T00:31:43Z","closed_at":null,"body":"**TypeScript Version:**  2.2.1\r\n\r\n**Actual behavior:**\r\nWith the new auto-import quick fix in TS2.2 (usable in VS Code), the suggested paths for missing imports are behaving strangely.\r\n\r\nIf I already have something imported from one package, let's say : \r\n`import { Component } from '@angular/core';`\r\nthen the auto-import quick fix for next missing imports from the same package will suggest the good solution : \r\n`\"Add OnInit from existing import declaration from @angular/core\"`\r\nresulting in : \r\n`import { Component, OnInit } from '@angular/core';`\r\n\r\nBut if nothing is yet imported from one package, the suggested auto-imports from quick fix will be : \r\n`\"Import OnInit from @angular/core/src/metadata\"`\r\n`\"Import OnInit from @angular/core/src/core\"`\r\n`\"Import OnInit from @angular/core/public_api\"`\r\n`\"Import OnInit from @angular/core/core\"`\r\nresulting for example in : \r\n`import { OnInit } from '@angular/core/core';`\r\nwhich is wrong.\r\n\r\n**Expected behavior:**\r\nAs it's a common pattern for a package to do a main entry file (index.ts), re-exporting all the public API, and for TypeScript to have a consistent behavior, the auto-import quick fix should suggest the top-level path only : \r\n`\"Import OnInit from @angular/core\"`\r\ninstead of low-level paths."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/294636027","html_url":"https://github.com/Microsoft/TypeScript/issues/15223#issuecomment-294636027","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/15223","id":294636027,"user":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars0.githubusercontent.com/u/8000722?v=3","gravatar_id":"","url":"https://api.github.com/users/mhegazy","html_url":"https://github.com/mhegazy","followers_url":"https://api.github.com/users/mhegazy/followers","following_url":"https://api.github.com/users/mhegazy/following{/other_user}","gists_url":"https://api.github.com/users/mhegazy/gists{/gist_id}","starred_url":"https://api.github.com/users/mhegazy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhegazy/subscriptions","organizations_url":"https://api.github.com/users/mhegazy/orgs","repos_url":"https://api.github.com/users/mhegazy/repos","events_url":"https://api.github.com/users/mhegazy/events{/privacy}","received_events_url":"https://api.github.com/users/mhegazy/received_events","type":"User","site_admin":false},"created_at":"2017-04-18T00:31:43Z","updated_at":"2017-04-18T00:31:43Z","body":"This is a bit tough, if you already have this in your file we defer to it; if not, we are trying to find the exported name in all modules that export it. we want to avoid IO as much as possible, so we do no load the packge.json, and that is what redirects `@angular/core` to `@angular/core/core.d.ts`.\r\n\r\nTo do this efficiently we need to keep a cache of package.json mappings to files, and do a reveres lookup to get the package name as a suggestions instead of the file."}}
{"actor":{"display_login":"mhegazy"}}