Skip to content
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

CodeFix import for items that exist globally #13378

Closed
normalser opened this issue Jan 10, 2017 · 4 comments
Closed

CodeFix import for items that exist globally #13378

normalser opened this issue Jan 10, 2017 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@normalser
Copy link

I'm not sure if this feature request is valid so just wanted to see what you think.

Let's say I have a react component called History.
As it happens there also exists global declare var History in lib.dom.d.ts

It would be nice that when using History in my module I could use CodeFix import action (Cmd+.) to be able to import my own component if there is no such local import. CodeFix bulb / shortcut keyboard is very discreet so there wouldn't be any worry of noise.

And I'm not sure how many other such cases could exist

@aluanhaddad
Copy link
Contributor

aluanhaddad commented Jan 10, 2017

So is the idea here that this would always be an available "refactoring" or is this for the scenario you have in mind one where you actually meant to import your History component and simply forgot?

@normalser
Copy link
Author

@aluanhaddad what I meant was this.

Imagine user has React component:

// File: history1.tsx
export const History = ()=> <div>...</div>

and he wants to reuse it in his other react components

// File: test.tsx
export const Test = ()=> <History/>

But because there happens to exist 'History' global variable - he is not able to use the most awesome recent feature of TS/Vscode called "CodeFix import" - no bulb and clicking Cmd+"." does nothing

Now the only way to make it work is to manually go to the top of the file and add import { History } from './history1' or to rename the component to something else (so it does not collide with some global type/item)

I was just wondering if it was make sense to have this logic:

If there is no import like import { History } from '....' in current file then still allow to use Cmd+. on History (in this example) to import "local component" into current file

List of global types/items is pretty big but still not sure if it's gonna be common scenario of defining own things that happen to have the same name as some globals

zbikq8ga78

@aluanhaddad
Copy link
Contributor

Thanks for clarifying. I like this idea.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 21, 2017

Duplicate of #7849. Fixed by #13921

@mhegazy mhegazy closed this as completed Apr 21, 2017
@mhegazy mhegazy added the Duplicate An existing issue was already created label Apr 21, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants