Skip to content

Commit

Permalink
separate cjs and mjs typings (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Nov 10, 2023
1 parent d024fff commit 3af3fa8
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 34 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 13.4.0

- fix: separate cjs and mjs typings

### 13.3.2

- types: fix consider importing '\*.js'
Expand Down
1 change: 1 addition & 0 deletions TransWithoutContext.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './TransWithoutContext.js';
1 change: 1 addition & 0 deletions icu.macro.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './icu.macro.js';
1 change: 1 addition & 0 deletions index.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './index.js';
1 change: 1 addition & 0 deletions initReactI18next.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './initReactI18next.js';
66 changes: 40 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 19 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "13.3.2",
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.",
"main": "dist/commonjs/index.js",
"types": "./index.d.ts",
"types": "./index.d.mts",
"jsnext:main": "dist/es/index.js",
"module": "dist/es/index.js",
"keywords": [
Expand All @@ -20,28 +20,40 @@
"exports": {
"./package.json": "./package.json",
".": {
"types": "./index.d.ts",
"types": {
"require": "./index.d.ts",
"import": "./index.d.mts"
},
"module": "./dist/es/index.js",
"import": "./dist/es/index.js",
"require": "./dist/commonjs/index.js",
"default": "./dist/es/index.js"
},
"./TransWithoutContext": {
"types": "./TransWithoutContext.d.ts",
"types": {
"require": "./TransWithoutContext.d.ts",
"import": "./TransWithoutContext.d.mts"
},
"module": "./dist/es/TransWithoutContext.js",
"import": "./dist/es/TransWithoutContext.js",
"require": "./dist/commonjs/TransWithoutContext.js",
"default": "./dist/es/TransWithoutContext.js"
},
"./initReactI18next": {
"types": "./initReactI18next.d.ts",
"types": {
"require": "./initReactI18next.d.ts",
"import": "./initReactI18next.d.mts"
},
"module": "./dist/es/initReactI18next.js",
"import": "./dist/es/initReactI18next.js",
"require": "./dist/commonjs/initReactI18next.js",
"default": "./dist/es/initReactI18next.js"
},
"./icu.macro": {
"types": "./icu.macro.d.ts",
"types": {
"require": "./icu.macro..d.ts",
"import": "./icu.macro..d.mts"
},
"default": "./icu.macro.js"
}
},
Expand Down Expand Up @@ -94,7 +106,7 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-testing-library": "^5.11.0",
"husky": "^8.0.3",
"i18next": "^23.4.5",
"i18next": "^23.7.1",
"jest": "^24.8.0",
"jest-cli": "^24.8.4",
"lint-staged": "^8.1.3",
Expand All @@ -107,7 +119,7 @@
"rollup": "3.25.1",
"sinon": "^7.2.3",
"tslint": "^6.1.3",
"typescript": "^5.1.3",
"typescript": "5.1.3",
"yargs": "^17.7.2"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
},
"include": ["./index.d.ts", "./@types/**/*", "./icu.macro.d.ts", "./test/**/*"],
"include": ["./index.d.mts", "./@types/**/*", "./icu.macro.d.mts", "./test/**/*"],
"exclude": ["test/typescript/nonEsModuleInterop/**/*.ts", "test/typescript/custom-types"]
}

2 comments on commit 3af3fa8

@adrai
Copy link
Member Author

@adrai adrai commented on 3af3fa8 Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, with mts it seems not to be possible anymore to overload the i18n interface...

> tslint --project tsconfig.json '**/*.{ts,tsx}'

DeprecationWarning: 'originalKeywordKind' has been deprecated since v5.0.0 and will no longer be usable after v5.2.0. Use 'identifierToKeywordKind(identifier)' instead.
/Users/adrai/Projects/i18next/react-i18next/index.d.ts:37:13
ERROR: 37:13  expect  TypeScript@next compile error:
Duplicate identifier 'i18n'.

/Users/adrai/Projects/i18next/react-i18next/test/typescript/context.test.tsx:5:9
ERROR: 5:9    expect  TypeScript@next compile error:
Property 'reportNamespaces' does not exist on type 'i18n'.
ERROR: 6:9    expect  TypeScript@next compile error:
Property 'reportNamespaces' does not exist on type 'i18n'.
image image image

I would be more than happy if someone could help me with this, unfortunately I'm not a TS expert...

@pedrodurek @JounQin @perrin4869 @me4502 @ubuntudroid @nicegamer7

@adrai
Copy link
Member Author

@adrai adrai commented on 3af3fa8 Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, this seems to fix it: i18next/i18next@85fd79b

Please sign in to comment.