-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix TypeScript declarations #121
Conversation
There's no default export, so don't use default exports in the type declarations. Also fixes a few other issues.
Thanks — not sure I understand what you mean by there being no default export? pkg.main has a |
An alternative way to fix this is to add a |
Gah. Looks like the problem here is that ts-node is importing pkg.main rather than pkg.module. Does that sound right? If so, adding |
It's not specific to ts-node. This is what TypeScript generates: "use strict";
exports.__esModule = true;
var magic_string_1 = require("magic-string");
new magic_string_1["default"]('abc'); So yeah, maybe do this? Object.defineProperty(MagicString, 'default', { value: MagicString }); |
Will do — though I consider the lack of interoperability a bug in TypeScript! |
Here's a long discussion about it: microsoft/TypeScript#2719. |
Lordy. Imagine if the JS gods had given us modules that didn't have privileged default exports, or if Node hadn't decided to tear up CommonJS 1.1 in the first place. We could probably have transitioned the whole ecosystem by now... |
Have released 0.21.2 with that change, so I'll close this. Thanks! |
There's no default export, so don't use default exports in the type declarations. Also fixes a few other issues.