-
Notifications
You must be signed in to change notification settings - Fork 503
yarn jest TypeError: xxx.default is not a constructor -- default export not output as expected #83
Copy link
Copy link
Closed
Labels
kind: bugSomething isn't workingSomething isn't workingkind: featureNew feature or requestNew feature or requestsolution: duplicateThis issue or pull request already existsThis issue or pull request already exists
Description
Current Behavior
tsdx yarn test will report error:
TypeError: xxx.default is not a constructor
when import a class created by tsdx and try to instance it.
reproduction:
- create a lib using
tsdx
tsdx create mylib-a- modify index.ts to a
class
// mylib-a/src/index.ts
export default class MyLibA {}- build
yarn build- create another lib using
tsdxcalledmylib-b - move
mylib-atomylib-b/src/ - import
mylib-ainmylib-b/test/blah.test.ts
import MyLibA from '../src/mylib-a';
// this line is error when `yarn test`
// TypeError: xxx.default is not a constructor
const instance = new MyLibA();- yarn test
If I don't use default to export class:
export class MyLibA {}And import like this:
import { MyLibA } from ...;Everything will be ok, but it is just a workaround.
Expected behavior
Suggested solution(s)
Additional context
Your environment
| Software | Version(s) |
|---|---|
| TSDX | ^0.5.6 |
| TypeScript | ^3.4.5 |
| Browser | - |
| npm/Yarn | yarn@1.13.0 |
| Operating System | macOS Mojave version 10.14.4 (18E226) |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind: bugSomething isn't workingSomething isn't workingkind: featureNew feature or requestNew feature or requestsolution: duplicateThis issue or pull request already existsThis issue or pull request already exists