{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/8213","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/8213/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/8213/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/8213/events","html_url":"https://github.com/Microsoft/TypeScript/issues/8213","id":149683141,"number":8213,"title":"Suggestion: Rename imports in modules locally  adding an import allias","user":{"login":"BBGONE","id":3954243,"avatar_url":"https://avatars.githubusercontent.com/u/3954243?v=3","gravatar_id":"","url":"https://api.github.com/users/BBGONE","html_url":"https://github.com/BBGONE","followers_url":"https://api.github.com/users/BBGONE/followers","following_url":"https://api.github.com/users/BBGONE/following{/other_user}","gists_url":"https://api.github.com/users/BBGONE/gists{/gist_id}","starred_url":"https://api.github.com/users/BBGONE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BBGONE/subscriptions","organizations_url":"https://api.github.com/users/BBGONE/orgs","repos_url":"https://api.github.com/users/BBGONE/repos","events_url":"https://api.github.com/users/BBGONE/events{/privacy}","received_events_url":"https://api.github.com/users/BBGONE/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/In%20Discussion","name":"In Discussion","color":"556b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-04-20T07:27:00Z","updated_at":"2016-04-20T19:39:44Z","closed_at":null,"body":"At  present if we rename an import  in Visual Studio Code editor it renames  globally throughout the project and  that includes the site of the definition.\r\n\r\nFor example if we rename BaseObject to MyObject  in the following import declaration:\r\n\r\n`import { BaseObject } from \"jriapp_core/object\";`\r\n\r\nThe uses of BaseObject will be renamed not only in the current module but in all other modules  too.\r\nIf BaseObject  was defined in type definition file object.d.ts  it will be renamed too.\r\nThat means that  after type def regeneration the project is broken.\r\n\r\n**So i  suggest if we rename an import (_as BaseObject to MyObject_)   then only add an  alias.**\r\n\r\n`import { BaseObject   as MyObject } from \"jriapp_core/object\";`\r\n\r\nThis is  correct  because imports are actually function arguments, so they are local to the module which imports them.  In  the case of importing type declaration as interfaces, they are just provided by reference and we rename only the reference's name -  not the actual type's name.\r\n\r\nThat behavior (at  present) also prevents us to find all references for  the import locally, because  it finds them in the whole project, and that is not useful to anybody at all.\r\n\r\nP.S.: and this is my comment from another issue #8118 which i appended after it had been  closed.\r\n\r\n_if we look more closely at renaming at the site of import instead of renaming at the site of declaration then we can see how things can be broken easily.\r\nFor example: we could have a definition file app.d.ts, and imported some types or variables into module1.ts, then at the site of import in module1.ts we rename that imported type and this will rename it to in the definition file too. But after regenerating the definition file our application is broken!\r\nAnother example, if we rename at the site of the import and that import is used in other modules too and the other modules use local variables with exactly the same name as we will rename in the first module, then we get a name collision in other modules - the imports will have the names of local variables or exports.\r\nIf we renaming at the site of declaration then we are aware of these possibilities, but if we rename at the site of import we are getting into it unawarely.\r\n_"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/212573972","html_url":"https://github.com/Microsoft/TypeScript/issues/8213#issuecomment-212573972","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/8213","id":212573972,"user":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars.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":"2016-04-20T19:39:44Z","updated_at":"2016-04-20T19:39:44Z","body":"sorry, i assumed you are using VSCode as the main IDE. so what is the IDE you are currently using?"}}