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

Offer an auto-import for unresolved shorthand-named object literal properties #32219

Open
alikazemkhanloo opened this issue Jul 2, 2019 · 9 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@alikazemkhanloo
Copy link

suppose I have exported an object called Foo in foo.js, and in another file I want to use something like this:

export default configure({Foo})

autocomplete will not show Foo and of course, will not auto import from that file.
to use auto import, I have to write the code like this:

export default configure({Foo:Foo})

actually autocomplete shows Foo, But it doesn't auto import. it has abc icon.
could you support object shorthand in autocomplete?

@vscodebot vscodebot bot assigned mjbvz Jul 2, 2019
@mjbvz
Copy link
Contributor

mjbvz commented Jul 2, 2019

Can you please share the definition of the configure function too?

@alikazemkhanloo
Copy link
Author

I'm using createStackNavigator function from react navigation.

createStackNavigator({
  screenName,
},{
  intialRouteName:'screenName'
})

@mjbvz
Copy link
Contributor

mjbvz commented Jul 2, 2019

So your code looks something like:

export default createStackNavigator({
  screenName,
},{
  intialRouteName:'screenName'
})

Is that correct?

@alikazemkhanloo
Copy link
Author

Yeap. And I want to auto-import screenName as I type for the first time. Now I should type something: screenName, for auto import to work.

@microsoft microsoft deleted a comment from vscodebot bot Jul 2, 2019
@mjbvz mjbvz transferred this issue from microsoft/vscode Jul 2, 2019
@mjbvz
Copy link
Contributor

mjbvz commented Jul 2, 2019

Ok sorry, I realize now this is not related to the configre call at all. You can repo this with:

// a.ts
export const abc = 123;
// b.ts
({ abc });

The reason we don't offer suggestion here is because it looks like you are defining a new property. Two actionable things for this issue:

  • Consider adding an add missing import quick fix for object shorthand values that are not import

  • Investigate offering suggestions while typing property names (because it could be shorthand). I suspect this would end up being pretty annoying in practice

@mjbvz mjbvz removed their assignment Jul 2, 2019
@RyanCavanaugh RyanCavanaugh added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript labels Jul 2, 2019
@RyanCavanaugh RyanCavanaugh changed the title auto import when using object shorthand Offer an auto-import for unresolved shorthand-named object literal properties Jul 2, 2019
@Justkant
Copy link

Justkant commented Sep 26, 2019

Hi, I have the same issue everytime I want to auto-import while using the shorthand syntax using VSCode.

@PetrBrabec
Copy link

Hello, I use shorthand-named object properties very often. What if there won't be any suggestions while typing property names, but you can hit cmd+. to see the suggestions? @mjbvz

@jdalley
Copy link

jdalley commented Feb 7, 2021

Is this something you folks might consider adding at some point? I definitely run into this quite a bit.

@d07RiV

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

7 participants