Skip to content
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

fix types for use() #912

Merged
merged 1 commit into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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