From 9e8c263bfc7630245620adc1517a31bd4dc76691 Mon Sep 17 00:00:00 2001 From: Kevin Ross Date: Thu, 1 Aug 2019 12:05:11 -0500 Subject: [PATCH] fix types for use() Depends on https://github.com/i18next/i18next/pull/1296 --- package.json | 4 ++-- src/index.d.ts | 9 +++------ test/typescript/I18nextProvider.test.tsx | 6 +++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 9fee3e78e..f8329d1ea 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "eslint-plugin-jsx-a11y": "6.2.1", "eslint-plugin-react": "7.12.4", "husky": "^1.3.1", - "i18next": "^15.0.7", + "i18next": "^17.0.8", "jest": "24.1.0", "jest-cli": "24.1.0", "lint-staged": "^8.1.3", @@ -75,7 +75,7 @@ "rollup-plugin-terser": "^4.0.4", "sinon": "^7.2.3", "tslint": "^5.13.1", - "typescript": "^3.3.3", + "typescript": "^3.5.3", "yargs": "12.0.5" }, "peerDependencies": { diff --git a/src/index.d.ts b/src/index.d.ts index 10c905fc2..f548dbba2 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,4 +1,4 @@ -import i18next from 'i18next'; +import * as i18next from 'i18next'; import * as React from 'react'; type Omit = Pick>; @@ -11,10 +11,7 @@ export function addUsedNamespaces(namespaces: Namespace[]): void; export function getUsedNamespaces(): string[]; export function setI18n(instance: i18next.i18n): void; export function getI18n(): i18next.i18n; -export const initReactI18next: { - type: string; - init(instance: i18next.i18n): void; -}; +export const initReactI18next: i18next.ThirdPartyModule; export function composeInitialProps(ForComponent: any): (ctx: unknown) => Promise; export function getInitialProps(): { initialI18nStore: { @@ -77,7 +74,7 @@ export function withTranslation( ns?: Namespace, options?: { withRef?: boolean; - } + }, ):

( component: React.ComponentType

, ) => React.ComponentType>; diff --git a/test/typescript/I18nextProvider.test.tsx b/test/typescript/I18nextProvider.test.tsx index 5249dc913..49323fc21 100644 --- a/test/typescript/I18nextProvider.test.tsx +++ b/test/typescript/I18nextProvider.test.tsx @@ -1,8 +1,8 @@ -import i18n from 'i18next'; +import * as i18next from 'i18next'; import * as React from 'react'; import { I18nextProvider, initReactI18next } from 'react-i18next'; -i18n.use(initReactI18next).init({ +i18next.use(initReactI18next).init({ fallbackLng: 'en', // have a common namespace used around the full app @@ -23,7 +23,7 @@ i18n.use(initReactI18next).init({ function test() { return ( Loading

}> - +

Foo