-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Bug] Typescript Declaration file error #1528
Comments
this will introduce a new problem, please refer to #1281 |
What is the problem ? I read through #1281 and did not found what you mean. You have already deleted module entry, so align Please list one of the problems, I am not catching you and I can not think out one. |
users must explicit use And they will read What are the acual problem? |
I have the same problem:
And that is a correct warning, as
So I agree with @Mister-Hope that
or perhaps I am missing an important side effect of such a change :-) |
Nope probably @iamkun isn't expert at ts. And since he used module field to trigger a side effect, he thinks all have a side effect 🤔 |
BTW I ran into the same problem when trying to import the |
Actually all the declaration files in esm needs to be corrected |
One more point: if Otherwise node will look up the tree for the next My only problem is that if we want to use the default export plus the destructuring imports at the same time we will have to redefine all exports in the .d.ts files (at least I didn't find a better way). I really don't like code duplication, but probably we will have to go this way. I'm still working of a PR to this. |
This will have sife effects in some situation. If a code wants to work both in cjs and esm when just exporting a function, it should use named export intead of default export. And this is the issue ikun run into. Now you should import Ikun will probably need to change to named exports and raise to v2 to include them in one package. |
Just to understand the problem I created demo projects for all cases:
Now IMHO @iamkun made the clever decision to integrate dayjs as esm package in the generated package in form of a subfolder called So in my program (that is using the dayjs package) if and only if I want to use If I do this with
This way we could have both worlds without using 2 packages ( Using 2 different packages is something we should avoid, as this makes development of this great package not really easier - I suppose. And to the question of semantic versioning: is this really a major (i.e. breaking) change? We only change the type definitions and at least I could not get the current type definitions into compiling without error - so does anyone else? Or does my "great" solution (just joking :-) miss some side effects that would kill any existing application using dayjs? At the moment all existing solutions should be using the path |
I addressed these points in pr #1581 |
Any update of this? |
1 similar comment
Any update of this? |
any update? |
There hasn't been any updates to |
Please convert dayjs/esm/index.d.ts to
export default dayjs
Declaration file is using
export =
which is same toexports
in cjs, while the actural code isexport default
which isexports.default
in cjs.This makes error when the env not allow users to open
allowSyntheticDefaultImports
andesModuleInterop
The text was updated successfully, but these errors were encountered: