How to migrate require -> import and module.exports -> export default
Hello
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
Hello 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-fullit 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
try this -> import * as validation from "express-validation"
try this -> import * as validation from "express-validation"
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...
It's just what it is :smile: (ES6 Syntax).. If You need any help you can always ask. Iam Ready to help.
I agree that it would be neat if ts-migrate handled CJS to ESM migration. However, in the meantime, there are other standalone codemods you can use for that.
Hey @NickHeiner which codemod are You suggesting?
I'm not suggesting one in particular. Just google for it. :smile:
@rysi3k any solution to this?
This seems to be the main one and it's working well. https://github.com/5to6/5to6-codemod