-
-
Notifications
You must be signed in to change notification settings - Fork 681
Typescript use export default for esm-first approach
#1352
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
Conversation
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. |
Depends on release of i18next/i18next#1352
Depends on release of i18next/i18next#1352
|
@rosskevin prefer major too...give me a few minutes to publish this. |
|
published in [email protected] |
* bump typescript * Update to use new ts export from i18next i18next/i18next#1352 * Update to i18next 19.0.0
Depends on release of i18next/i18next#1352
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
esModuleInteropsetting (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: trueusersNO 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.
--esModuleInteropbeing exactly for the purpose of loading legacy commonjs. (Note that i18next provides both commonjs and esm packages)ts-jestdocs, it is expected that if you load commonjs code, you need to useesModuleInterop: true.It ultimately comes down to this:
i18nextis 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