-
-
Notifications
You must be signed in to change notification settings - Fork 645
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 use export default
for esm-first approach
#1352
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rosskevin
added a commit
to rosskevin/test-i18next
that referenced
this pull request
Oct 29, 2019
manual copy of types from i18next/i18next#1352
@jamuhl this is a typescript-only breaking change. It is your call on what to do with semver here. I can argue for a major or minor bump. If I were persuaded in one direction, on this case it would be major. I will be following on with PRs for other i18next projects to deal with the ts interop tests/imports. |
rosskevin
added a commit
to rosskevin/react-i18next
that referenced
this pull request
Oct 29, 2019
rosskevin
added a commit
to rosskevin/i18next-browser-languageDetector
that referenced
this pull request
Oct 29, 2019
Depends on release of i18next/i18next#1352
rosskevin
added a commit
to rosskevin/i18next-xhr-backend
that referenced
this pull request
Oct 29, 2019
Depends on release of i18next/i18next#1352
@rosskevin prefer major too...give me a few minutes to publish this. |
published in i18next@19.0.0 |
rosskevin
added a commit
to i18next/react-i18next
that referenced
this pull request
Oct 29, 2019
* bump typescript * Update to use new ts export from i18next i18next/i18next#1352 * Update to i18next 19.0.0
danielweck
added a commit
to edrlab/thorium-reader
that referenced
this pull request
Oct 31, 2019
This was referenced Nov 6, 2019
This was referenced May 20, 2020
7 tasks
goldentroll
added a commit
to goldentroll/i18next-browser-languageDetector
that referenced
this pull request
Mar 14, 2023
Depends on release of i18next/i18next#1352
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rationale
Long history, explanation and rationale in issue #1351. The runtime and pure javascript remains unaffected.
Moving forward
Use the following import styles regardless of the
esModuleInterop
setting (sample imports of default and named below, choose the one that fits your use case):import i18next from 'i18next'
import {TFunction} from 'i18next'
import i18next, {TFunction} from 'i18next'
Implications for
esModuleInterop: true
usersNO CHANGE at all! Yay.
Implications for
esModuleInterop: false
(default) usersThis is a sample change set for someone that uses both a default and a named import. Adjust imports to your use case accordingly as mentioned above.
esModuleInterop
) or with@std/esm
(open issue about jest support)These breakages are expected and intended.
--esModuleInterop
being exactly for the purpose of loading legacy commonjs. (Note that i18next provides both commonjs and esm packages)ts-jest
docs, it is expected that if you load commonjs code, you need to useesModuleInterop: true
.It ultimately comes down to this:
i18next
is just an ecmascript library.Loading semantics of webpack, node, jest and other tools are not in the purview of this project. This change recognizes that understanding and aligns the typescript types exactly with the source code and we are using an esm-first approach moving forward.
I ask that before registering a dissenting comment here, please look at the linked issue, repository with reproductions and all the research I documented over the past eight hours of work. This is a seemingly innocuous change that will affect some typescript users, but it has been thoroughly researched and it is in-line with typescript recommendations.
Closes #1351