How to migrate require -> import and module.exports -> export default
See original GitHub issueHello
I have tried to use this package, but I have problem with auto migrate require to import and exports to export default.
Now when I ran npx ts-migrate-full
it leaves me many lines:
// @ts-expect-error ts-migrate(2451) FIXME: Cannot redeclare block-scoped variable 'validation... Remove this comment to see the full error message
const validation = require('express-validation');
IMHO it should be migrated to import lines. Maybe I’m missing something? Or I should migrate it manually first?
Regards Tomasz
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:8
Top Results From Across the Web
module.exports vs. export default in Node.js and ES6
We can import the module in two ways: Either using CommonJS or using ES6 import syntax. Your issue: I believe you are doing...
Read more >Node Module Exports Explained – With JavaScript ...
Default exporting in a Node.js module is as simple as this: ... Node.js modules can import by require -ing the exported value.
Read more >export - JavaScript - MDN Web Docs
Every module can have two different types of export, named export and default export. You can have multiple named exports per module but...
Read more >Module Exports vs. Export Default: Why Not Both?
Simplify usage: Having a default export simplifies import when the person importing the module just wants the obvious thing from there. · Signal ......
Read more >ES6 Modules and How to Use Import and Export in ...
You can also give an aliases to exported members with the as keyword: ; You can define a default export with the default...
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
This seems to be the main one and it’s working well. https://github.com/5to6/5to6-codemod
I have no problem with fix this issue, but I’m wondering what prevents ts-migrate from migrate require -> import and module.exports -> export default ? I have almost 100 files, with many imports in each file, fixing it manually is horrible job…