question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TS auto import should support configuring whether a star or a qualified import is used.

See original GitHub issue

From @dbaeumer on October 31, 2017 11:29

Testing: #37177

  • vscode source code opened in VS Code
  • open a file that doesn’t import 'vs/base/common/types'
  • type isStringArray
  • select the entry from code complete list
  • the following import is inserted:
import { isStringArray } from 'vs/base/common/types';

However what I want in this case is

import * as Types from 'vs/base/common/types';

and the code should become Types.isStringArray

Would be cool if I can control this via a setting.

Copied from original issue: Microsoft/vscode#37258

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:14
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
katiscommented, Nov 12, 2019

I would be happy if I could write an item name, find it in the completion list, press <SOME_MODIFIER>+Tab/Enter and have it import the thing as qualified. You could pick the name from file/module the item belongs to, with a kebab-/snakecase converted to camelcase. Rename refactoring could be then used on the qualified name if needed.

i.e.

getName completion could become:

import * as User from `some/module/User`

...

User.getName
3reactions
octrefcommented, May 11, 2018

Copying my original problem here:

For example, now if I type resolve, VS Code auto suggests millions of resolve from all libraries. This is not helpful:

image

For me, I usually have this

import * as path from 'path'

path.resolve(...)

However now path. doesn’t have any auto import associated with suggestions.

I hope path. can generate completion items that when accepted, add automatic imports to top. The expected behavior is:

  • Type path.
  • VS Code should auto complete, based on either type definition at @types/node or the Automatic Type Acquisition
  • When user accepts path.resolve, add to top of file import * as path from 'path'

I think if one types resolve, auto import import { resolve } from 'path' makes sense. However when one types path.resolve, auto import should do import * as path from 'path'.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto import | IntelliJ IDEA Documentation - JetBrains
Basic procedures to create and optimize imports in IntelliJ IDEA. Learn more how to import the missing import or XML namespace.
Read more >
Is there auto-import functionality for typescript in Visual Studio ...
Automatically searches for TypeScript definitions in workspace files and provides all known symbols as completion item to allow code completion.
Read more >
Untitled
If you need to use a lot of classes from a certain Java package, ... You can also add classes and packages to...
Read more >
Language Support for Java(TM) by Red Hat
java.import.exclusions : Exclude folders from import via glob patterns. Use ! to negate patterns to allow subfolders imports. You have to include a ......
Read more >
Stevens Creek Auto Imports in San Jose, CA - Capital One
Find new and used cars at Stevens Creek Auto Imports. ... Remember, you can use your mobile phone to configure pre-qualified financing for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found