Skip to content

Commit

Permalink
fix types for use() (#912)
Browse files Browse the repository at this point in the history
  • Loading branch information
rosskevin authored Aug 1, 2019
1 parent aeb8078 commit 5e41c7a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
9 changes: 3 additions & 6 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import i18next from 'i18next';
import * as i18next from 'i18next';
import * as React from 'react';

type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
Expand All @@ -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<any>;
export function getInitialProps(): {
initialI18nStore: {
Expand Down Expand Up @@ -77,7 +74,7 @@ export function withTranslation(
ns?: Namespace,
options?: {
withRef?: boolean;
}
},
): <P extends WithTranslation>(
component: React.ComponentType<P>,
) => React.ComponentType<Omit<P, keyof WithTranslation>>;
Expand Down
6 changes: 3 additions & 3 deletions test/typescript/I18nextProvider.test.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,7 +23,7 @@ i18n.use(initReactI18next).init({
function test() {
return (
<React.Suspense fallback={<p>Loading</p>}>
<I18nextProvider i18n={i18n}>
<I18nextProvider i18n={i18next}>
<h1>Foo</h1>
</I18nextProvider>
</React.Suspense>
Expand Down

0 comments on commit 5e41c7a

Please sign in to comment.