JS/TS: Convert 'require' to 'import' fails
See original GitHub issueIssue Type: Bug
Steps to reproduce:
- In a Typescript file, write import statement using require:
const foo = require('./foo')
- On ‘require’, trigger “Quick fix” menu and select “Convert ‘require’ to ‘import’”
Actual output: import foo = require('./foo')
Expected output: import {foo} from './foo'
I can confirm that I was using this feature about a week ago and it was correctly formatting the output, so this must be a bug introduced by a recent update.
VS Code version: Code 1.54.3 (2b9aebd5354a3629c3aba0a5f5df49f43d6689f8, 2021-03-15T11:57:12.728Z) OS version: Darwin x64 19.6.0
System Info
Item | Value |
---|---|
CPUs | Intel® Core™ i7-9750H CPU @ 2.60GHz (12 x 2600) |
GPU Status | 2d_canvas: enabled gpu_compositing: enabled metal: disabled_off multiple_raster_threads: enabled_on oop_rasterization: enabled opengl: enabled_on protected_video_decode: unavailable_off rasterization: enabled skia_renderer: disabled_off_ok video_decode: enabled webgl: enabled webgl2: enabled |
Load (avg) | 5, 2, 2 |
Memory (System) | 32.00GB (3.95GB free) |
Process Argv | -psn_0_53261 --crash-reporter-id f2039b3f-4da2-4e10-a09d-f641c4c7a6fe |
Screen Reader | no |
VM | 0% |
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstry244:30276681
pythonvsdeb440:30248342
pythonvsded773:30248341
pythonvspyt875:30259475
pythontbcf:30265426
vscoresta800cf:30279782
vspre833cf:30267465
pythonptprofiler:30281270
vsdfh931cf:30280410
vshan820:30276952
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Cant convert 'require' to 'import' in TS · Issue #97645 - GitHub
Simply make a ts file and import anything by using CommonJS; Quick Fix > Convert all 'require' to 'import'. Does this issue occur...
Read more >Cannot import npm modules after converting ES5 require to ...
I am trying to convert my npm package imports from ES5 (require) to ES6 (import...from) but I keep getting unexpected identifier errors.
Read more >ATA Carnet Frequently Asked Question (FAQ's)
Is an import or export license required in conjunction with a Carnet?
Read more >Using JSTS isValid() with ES6 modules - GIS Stack Exchange
The WKTReader in JSTS assumes valid WKT and will throw on invalid WKT. Also, the import in the above example is wrong. It...
Read more >At Half The Price Of Rafales - Why Did India Turn Down SAAB ...
Despite Rafale jets winning the first duel against Gripen, ... concept offered by SAAB is a good example of transfer of technologies and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @RyanCavanaugh I believe issue missed getting assigned to the correct TS owner since I forgot to unassign myself. Could you please make sure it gets to the correct person on the TS team
@mjbvz & @Tyriar any updates in terms of whether I should provide more information on this?