[Fixed] How to migrate require import to es6 import with currying


I am migrating a node/express server to typescript. I could now use import syntax instead of require. However, I used to apply currying to shorten imports. How to translate these imports into es6 imports?

const app = require("express")();
const server = require("http").createServer(app);
const io = require("socket.io")(server);


    1. add "type": "module" in package.json
    2. start using 
          import {Name} from './index.js';

For your example : 

import express from 'express';
import http from 'http';
import { Server } from "socket.io";

const app = express();
const server = http.createServer(app);
const io = socketIO(server);
app.set('socketio', io);

Leave a Reply

(*) Required, Your email will not be published