ezolenko / rollup-plugin-typescript2

Rollup plugin for typescript with compiler errors.
MIT License
819 stars 71 forks source link

`error TS2349: This expression is not callable` when importing rpt2 #455

Closed cowwoc closed 1 year ago

cowwoc commented 1 year ago

When I try compiling code that uses your library with Typescript 5.1.6 I get the following error:

error TS2349: This expression is not callable.
  Type 'typeof import("C:/Users/Gili/Documents/requirements.js/node_modules/rollup-plugin-typescript2/dist/index")' has no call signatures.

If I replace rollup-plugin-typescript2 with rollup-plugin-typescript this error disappears (but of course then I get a warning about missing @types)

agilgur5 commented 1 year ago

Please don't remove the issue template, it's there for a reason.

rpt2 has a sizeable test suite, dogfoods itself, and has active reproduction environments. All of these currently work without errors. As a result, I cannot reproduce this.

An error message with no reproduction or details leaves us with almost no way of debugging. Please fill out the issue template, as is expected for all users and as is common courtesy for open-source projects.

The one tiny thing I can ascertain from the few details here is that the import is coming from dist/index, but rpt2's package.json#main is not a file named index; there is no such file dist/index.js.

cowwoc commented 1 year ago

Sorry. As you predicted, I can no longer reproduce this issue. I'll reopen if I ever run across this again. Thanks.

agilgur5 commented 1 year ago

I think I stumbled upon something similar when making changes to our internal build. If you use a namespace import, as in:

import * as rpt2 from "rollup-plugin-typescript2";

and then try to use rpt2(), you'll get this error, as the namespace is indeed not callable.

The correct syntax per the docs is to use the default import:

import rpt2 from 'rollup-plugin-typescript2';