-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Vscode not import types and values declaration correctly when they are in same file #136769
Comments
Does this reproduce in the latest VS Code insiders build with TS 4.5+? |
|
The current insiders version is 1.63. Please test using it and also make sure the workspace version of TS is 4.5+ (not just tsc) |
@mjbvz sry ! , it taked me time to have a free moment. I installed Insider and confirm the insider have same behavior with the rule
and seem ts 4.5.1-rc I take time to make you a little gif also if it can help to understand what i mean with my lack of English 😁
NOTE: also we should not forget new ts version will allow type tag inside the same import So this will be also valide in next release: // valide pattern 1
// valide pattern 2
|
Thanks for testing. As you note, the way the import is added is fine — and seems preferable in most cases to having two imports for the same file. We generally don't adapt our generic TS behavior to very specific eslint rules like this unless we get significant feedback (and the existing behavior has been in place for a while) Therefore I'm closing this as by-design |
Does this issue occur when all extensions are disabled?: yes
Version : 1.62.0 (user setup)
Commit : b3318bc
Date : 2021-11-03T15:23:01.379Z
Electron : 13.5.1
Chrome : 91.0.4472.164
Node.js : 14.16.0
V8 : 9.1.269.39-electron.0
OS : Windows_NT x64 10.0.19042
Steps to Reproduce:
Hi everyone, is it possible to maybe add a option to separate type and value import correctly, because this give big head hash if we use a ts rule like:
"importsNotUsedAsValues": "error",
Example if we have 2 file without
import
:test1.ts
test2.ts
And we mouse hover
const x:string = A
;Vscode will suggest fix to import value
And vscode will write for you the import, this is perfect and super productive !
result:
import { A } from './test1';
After if we mouse over the second declaration
Vscode will suggest import as value in same import declaration
result:
import { A, helperA } from './test1';
This is maybe correct but is not what we want if we use rule like
"importsNotUsedAsValues": "error",
Vscode should understand this rule and suggest **add this as type separately **
Expected result:
Because actually import type and value in the same import make broken some bundler like vitejs.
Error like
Uncaught SyntaxError: The requested module '/src/core/test1.ts?t=1636477934311' does not provide an export named 'Interpreters'
So i need to always manually change the import made by vscode, where is little waste of time !
or change my rule by
"importsNotUsedAsValues": "remove"
where is not what i want !Here related discutions that's explain this new issue.
evanw/esbuild#1525
microsoft/TypeScript#43393
So to make everything fine, i think if we can maybe add a setting in vscode to say
Prefer import type and value separately
it will be niceNo more need to hack manually what Vscode suggest when import stuff !
I say add a new option, if for you, because i dont know this can affect some other pattern of project, but on my side i want keep error, and allowed to import type and concret from same file
(i know it recommend to separate types and values, but it recommend, is not a law !).
thanks
The text was updated successfully, but these errors were encountered: