-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Use node require for auto imports? #20292
Comments
In our case, the feature is really more of an annoyance than anything else and I don't see how that could be solved. Even if the issues pointed out @mjbvz are resolved, the automatic insertion does not respect code style guidelines to the extent that it would be acceptable.
The biggest issue is that this happens out of sight and fails commits and/or builds due to code style violations. Handling this costs far more time than any auto-insertion of a statement would have saved. IMHO, this should have been implemented through one of those little light bulb quick-actions, instead of auto-inserting the statement during auto-completion. |
This is a bug that we are fixing. #20293 tracks that.
I suppose
tracked by #18780
You can always disable the feature using |
How is this determined in a pure JavaScript context?
I tried that. I put it into my workspace settings. It has no effect. After writing this, I realized that it is probably a user setting, which then worked. So, yay. I'm actually not too concerned with the implementation details, because I doubt that this could be reasonably implemented without a clear definition of the user's desired code style anyway. I initially reported this as an issue because I was frustrated about this being enabled by default and having a negative impact on productivity (which is probably the opposite of what the feature wants to achieve). I feel this was enabled prematurely. However, I should have realized earlier that the user settings control this behavior. Then I would have saved me said frustration. |
Default is ES6, you can change it in
That is fair. we have been getting reports for adding configuration for style options like so. I think that is something we will be adding as we go. our preference however is to make it smart enough that it works out of the box, e.g. trying to infer the quote from the current file. or use a standard-compliant pattern that most ppl would find agreeable, e.g. using |
Hi @mhegazy - in my tsconfig.json, my compilerOptions module is set to "None". I am not using ES6 modules. VsCode is inserting import statements at the top of the file. Should it? |
I think it would be great to have a configuration option that generates |
Just to add: There are definitely times when both Failing that, at least a way to disable auto import for some files. I'm woking with a Gatsby project at the moment and I'm having to remember to go and change every import for the node-related code. |
Could TypeScript auto-import with |
From microsoft/vscode#38773
Repo
Using the same project as #19629:
Accept the completion for
RelativePattern
fromvscode
Expected
Respects existing module style and adds
require
:Actual
import
inserted before everything else in the document:The text was updated successfully, but these errors were encountered: