Skip to content
This repository has been archived by the owner on Jul 23, 2020. It is now read-only.

New version is not working with TypeScript without esModuleInterop but there is no warning #245

Open
raszi opened this issue Apr 3, 2020 · 0 comments

Comments

@raszi
Copy link

raszi commented Apr 3, 2020

Given the following TypeScript code:

import JiraClient from "jira-connector";
const client = new JiraClient({ host: 'jira.foo.bar' });

With version 2.16.1, when trying to compile without esModuleInterop it gives me an error:

$ npx tsc index.ts
index.ts:1:8 - error TS1259: Module '"/Users/ikaraszi/tmp/node_modules/jira-connector/index"' can only be default-imported using the 'esModuleInterop' flag

1 import JiraClient from "jira-connector";
         ~~~~~~~~~~

  node_modules/jira-connector/index.d.ts:8:1
    8 export = JiraClient;
      ~~~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.


Found 1 error.

Works fine when I add the option:

$ tsc --esModuleInterop index.ts
$ node index.js

After 3.0.0, there is no error at the compile phase but the compiled version is not working:

$ npx tsc index.ts
$ node index.js
/Users/ikaraszi/tmp/index.js:4
var client = new jira_connector_1["default"]({ host: 'jira.foo.bar' });
             ^

TypeError: jira_connector_1.default is not a constructor
    at Object.<anonymous> (/Users/ikaraszi/tmp/index.js:4:14)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

And working when I add the compile option:

$ npx tsc --esModuleInterop index.ts
$ node index.js
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant