Closed yoshiokatsuneo closed 6 years ago
Workaround:
const Penpal = require('penpal').default;
Hey @yoshiokatsuneo, do you know how to fix this issue? I don't use TypeScript, so it might take me a while to figure it out. A pull request is welcomed.
@paulblyth, could you help out here perchance?
Hey, so we use:
import Penpal from 'penpal';
We’re on Penpal ^2.7.0 and Typescript 2.4.0 and we don’t get this error. Let me try with the versions above once I get into the office and I’ll get back to you.
I’m on mobile but fairly sure this is the error https://github.com/Aaronius/penpal/commit/8b05093b266c4d6d3f590ddab32b5b726fd3e11e
I don’t think you can have multiple exports in the module (I could be wrong but this is my best guess until I’m at a computer)
@yoshiokatsuneo could you please try https://github.com/Aaronius/penpal/pull/17 and let me know if that fixes it for you?
@paulblyth Unfortunately not...
$ npm install -g typescript
$ mkdir test
$ cd test
$ npm init -y
$ git clone https://github.com/Aaronius/penpal
$ pushd penpal
$ npm install
$ npm run-script build
$ popd
$ cat > test.ts
import Penpal from './penpal';
console.log(Penpal);
$ tsc test.ts
penpal/lib/index.d.ts(33,21): error TS2693: 'Promise' only refers to a type, but is being used as a value here.
penpal/lib/index.d.ts(43,3): error TS2309: An export assignment cannot be used in a module with other exported elements.
test.ts(1,20): error TS2306: File '/private/tmp/test/penpal/lib/index.d.ts' is not a module.
It just works if I just remove index.d.ts ...
Thanks @yoshiokatsuneo but I don't see anywhere where you've checked out the PR fix in that code snippet, looks like you're just testing against master? I've tried the steps you've done against my fork/branch and I still get a couple of errors but I'm not convinced they're not red herrings...
I've set up a quick demo here: https://github.com/paulblyth/penpal-ts-test - @Aaronius this might be useful for you too.
Let me know if you run into any issues.
Merry Christmas!
@paulblyth I just tested using the PR branch in my project. : https://github.com/paulblyth/penpal/tree/fix-16/multiple_exports And, it just works !
Fixed in 3.0.1.
I try to import Penpal like this.
Error:(43, 3) TS2309: An export assignment cannot be used in a module with other exported elements.
export = Penpal;
import Penpal from 'penpal';
Error:(3, 8) TS1192: Module ''penpal'' has no default export.