You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add option to disable TS using inline import types in quick fixes #35078
We should always prefer an import statement at the top of the file.
In that fix, we didn’t discuss adding an option, we just made it always do an import declaration. Matt Bierner (@mjbvz) do people really want an option, or does it seem like most people just want the import declaration?
It should also be noted that #35200 could have an impact on this discussion, so we may want to wait and see where it lands, particularly on whether the default behavior of the compiler’s elision of imports used only in type positions is going to change.
Andrew Branch (@andrewbranch) Yes I think VS Code would prefer that imports always be added at the top of the file. I'm not sure if other users prefer inline imports however, which is why I proposed having a setting to control this. We should try getting actual user feedback on this
On one hand, auto-imports will not use import type, so maybe we should match that here and use a regular import at the top of the file. On the other hand, that has unwanted effects if importsNotUsedAsValues is preserve or error. Could that be used as a heuristic to write a type-only import? (And actually, should that same heuristic be used for auto-imports?)
For VS Code, we would prefer adding regular imports. I agree though that this should not introduce an error, so observing importsNotUsedAsValues and using import type instead makes sense to me
Reacted by Andrew Branch, Philippe Vaillancourt and 流浪大法师
Activity
bpasero commentedon Nov 13, 2019
Duplicate of #34995
andrewbranch commentedon Dec 10, 2019
In #32910, Daniel Rosenwasser (@DanielRosenwasser) said
In that fix, we didn’t discuss adding an option, we just made it always do an import declaration. Matt Bierner (@mjbvz) do people really want an option, or does it seem like most people just want the import declaration?
It should also be noted that #35200 could have an impact on this discussion, so we may want to wait and see where it lands, particularly on whether the default behavior of the compiler’s elision of imports used only in type positions is going to change.
mjbvz commentedon Dec 10, 2019
Andrew Branch (@andrewbranch) Yes I think VS Code would prefer that imports always be added at the top of the file. I'm not sure if other users prefer inline imports however, which is why I proposed having a setting to control this. We should try getting actual user feedback on this
Also 👍 for #35200
andrewbranch commentedon Jan 24, 2020
Matt Bierner (@mjbvz) Daniel Rosenwasser (@DanielRosenwasser): with type-only imports in master, the discussion at #36038, and #36412 looking likely to be merged, what’s the latest feeling on the right thing to do here?
On one hand, auto-imports will not use
import type, so maybe we should match that here and use a regular import at the top of the file. On the other hand, that has unwanted effects ifimportsNotUsedAsValuesispreserveorerror. Could that be used as a heuristic to write a type-only import? (And actually, should that same heuristic be used for auto-imports?)mjbvz commentedon Jan 25, 2020
For VS Code, we would prefer adding regular imports. I agree though that this should not introduce an error, so observing
importsNotUsedAsValuesand usingimport typeinstead makes sense to me