Search code examples
typescriptimportcommonjs

How it is possible to import express from 'express' without a default export?


Using typescript and installing @types/express it is possible to import the express as a default, but there's no export default on express index.d.ts. I know there's the flag allowSyntheticDefaultImports, but even setting to true i can't replicate the same effect. How is this possible? I can't find the nomenclature and related questions for this.


Solution

  • It's possible with the line:

    export = e;
    

    This thread and more specifically this comment have nice explanations about how different export/import work