-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
No named or default exports available #36
Comments
That shouldn't be the case. Declaration files are ts, and ts doesn't do extensions. It's works perfectly fine for me. 🤔 |
Well esm requires extensions. https://www.typescriptlang.org/docs/handbook/esm-node.html |
the in-point of the package is here: dist/index.es.js There are no syntax errors in there. The type declaration file is auto generated and is pure typescript. It has nothing to do with esm. Type declaration files only need to adhere to typescript syntax and are only used by the code editor. Your build pipeline won't even use these. |
ok then. |
I'm happy to merge PRS or try to work on the issue if you're able to provide me with a reproduction. I'm pretty sure it's something related to the build step of your project. Happy too help out and have a look. Free of charge. |
Well you have tyoe = module. ESM/typescript requires extensions. simple as that. You have the tsconfig I use. Using moduleResolutiion nodeNext I have no idea how that could work for you. Sounds like you are using "node" module resolution and/or older settings. If you have a semi close sandbox I can modify it to show. |
I literally spent hours migrating to esm - so yes extensions are absolutely required (sadly - not a fan of it). The moment I added the extensions to that file above it all worked fine. |
The issue might be upstream. it seems that this plugin does not create the correct Can you try contacting there as well? |
Sorry but I moved on to another package - happy to try a new version though |
Do you use TSC to bundle your package/project? Or do you use something else like esbuild/rollup? |
I use tsx. But should not matter - https://www.typescriptlang.org/docs/handbook/esm-node.html specifically states "relative import paths need full extensions (e.g we have to write import "./foo.js" instead of import "./foo")". There are ways to work around that with various module resolutions but at end of the day that's what needed moving forward with full esm - here's another blog https://2ality.com/2021/06/typescript-esm-nodejs.html covering that. |
I think we'll have to tweak the usage of the 'rollup-plugin-typescript2' package in the build script. Do you have any hints how outputting .js extensions inside the generated .d.ts files can be achieved ? |
What happens if you add extensions in your code? like
Does it break things? |
@cyberwombat i am at a Sinterklaas event today but will try when I get home tonight !! |
@cyberwombat it worked by manually adding I wonder if VSCode has some auto complete for this, because I'm afraid I might forget in the future 🤔 |
VSCode should add extensions manually if package is type module which you have and tsconfig has certain settings (which I posted above). My VSCode certainly does it automatically and also shows errors if not (that might be eslint doing that). Thank you for fixing that! |
Tried it and it works. One thing I did notice - it seems I have to cast the result as unknown then as my return type which seems cumbersome - not sure if it can be made easier. |
TS should merge the types correctly. Can you open a new issue with the objects you put into merge that give you the faulty type ? I will take a look and see where it's going wrong. |
I'll see if I can - it happens when I am using complex imported types from some aws lib so not super easy to show. |
Using v ^5.1.3 and:
I get "Module '"merge-anything"' has no exported member 'merge'". I have tried default export as well. I am using type="module" in my package.json as well as this for my TSConfig:
I think there is something missing in package. If I click (using VSCode) on "merge-anything" it takes me to the declaration file:
For ESM exports these need extensions. So:
And then it works.
The text was updated successfully, but these errors were encountered: