-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
v11: fix for typescript definitions when using isolated modules #1627
Conversation
🦋 Changeset is good to goLatest commit: 79012d8 We got this. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 79012d8:
|
Hm, I would say this deserves a changeset as well - we are releasing prereleases often and seeing this in a changelog might help somebody. We will probably have to clean up the generated changelog before releasing final v11 anyway (to keep there only things that actually were done and to avoid noisy stuff). Thanks for the PR! I wouldn't know that this has such effect without investigating this for quite a bit of time probably, so this is a great time-saver ❤️ |
@@ -2,6 +2,7 @@ | |||
"compilerOptions": { | |||
"baseUrl": "../", | |||
"forceConsistentCasingInFileNames": true, | |||
"isolatedModules": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you see any downsides of using this in here? I can't think of any, cc @JakeGinnivan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isolatedModules
will cause the compilation to emit errors if the code is not able to be transpiled in single-file mode (ie. babel or ts.transpile). So it will raise errors for doing type re-exports or using const enums. AFAIK all other errors will also be emitted so I think it is safe to keep it turned on and it may even be worth adding it to the other configuration files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some info about the impact here: microsoft/TypeScript#16351
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it may even be worth adding it to the other configuration files.
Yeah, I was thinking about this as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add that to the PR if you want when I get home this evening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged this one in as we can add this flag in other configs in separate PR. Thanks for the fix!
Co-Authored-By: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Mateusz Burzyński <mateuszburzynski@gmail.com>
…bination with `isolatedModules` option (emotion-js#1627) * fix for typescript definitions when using isolated modules * add changeset * Update .changeset/odd-insects-cough.md Co-Authored-By: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update .changeset/odd-insects-cough.md Co-Authored-By: Mateusz Burzyński <mateuszburzynski@gmail.com>
Renaming:
styled/types/base.ts
tostyled/types/base.d.ts
styled/types/helper.ts
tostyled/types/helper.d.ts
Because when importing
@emotion/styled/base
with isolatedModules turned on, TypeScript was giving a compiler error:This happens because when transpiling a re-export with isolatedModules turned on TypeScript does not know if the exported item is a type or a runtime object and so cannot elide re-exported types.
By renaming the files to be definition files, this restriction no longer applies.
Checklist:
I have not created a changeset as this PR is against
next
and will go out with the next prerelease.Thanks for all your hard work, really looking forward to the improvements in v11.
Let me know if you need me to make any more changes or create a changeset.