Skip to content
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

TypeScript declaration is wrong in CommonJS #136

Open
tomdale opened this issue Apr 21, 2017 · 6 comments
Open

TypeScript declaration is wrong in CommonJS #136

tomdale opened this issue Apr 21, 2017 · 6 comments

Comments

@tomdale
Copy link
Collaborator

tomdale commented Apr 21, 2017

The .d.ts file exports a default class, which makes TypeScript look for a .default property on the exports object in CommonJS. However, in CommonJS environments, the exports object is set to the class itself. This makes it unusable in Node.js/TypeScript projects.

@krisselden
Copy link
Collaborator

You can fix by telling rollup to force default export but this will make people need require("x").default but if you don't do this it will happen as soon as someone adds a named export

@krisselden
Copy link
Collaborator

I think if we want interop it is best to avoid module.exports assignment altogether

@tomdale
Copy link
Collaborator Author

tomdale commented Apr 29, 2017

@krisselden I agree. Personally, I don't mind having to do .default in Node, but that may be a minority opinion.

calebboyd added a commit to calebboyd/route-recognizer that referenced this issue Jan 14, 2018
this is likely a breaking change for Node.js/JS users.

closes tildeio#136
@jvanoostveen
Copy link

Is there a change this being merged in for a new version?

@atheros
Copy link

atheros commented Apr 2, 2019

I was really hoping to use this lib in one of my project, because I was sure I could share code between frontend and backend, but I guess I was wrong :(

calebboyd added a commit to calebboyd/route-recognizer that referenced this issue Jan 22, 2020
this is likely a breaking change for Node.js/JS users.

closes tildeio#136
@calebboyd
Copy link

FWIW this is now solved by typescript with the allowSyntheticDefaultImports option, otherwise the typedef matches the module build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants