Skip to content

Commit

Permalink
missing named exports for TypeScript usage, fixes #1692
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Nov 16, 2021
1 parent 2f56df9 commit e7a9dd4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 21.5.2

- missing named exports for TypeScript usage [1692](https://github.com/i18next/i18next/issues/1692)

## 21.5.1

- add package.json to exports subpath
Expand Down
20 changes: 20 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,11 @@ export interface i18n {
*/
setDefaultNamespace(ns: string): void;

/**
* Changes the default namespace.
*/
hasLoadedNamespace(ns: string, options?: Pick<InitOptions, 'fallbackLng'>): void;

/**
* Returns rtl or ltr depending on languages read direction.
*/
Expand Down Expand Up @@ -1146,3 +1151,18 @@ export interface i18n {

declare const i18next: i18n;
export default i18next;

export const createInstance: i18n['createInstance'];

export const init: i18n['init'];
export const loadResources: i18n['loadResources'];
export const reloadResources: i18n['reloadResources'];
export const use: i18n['use'];
export const changeLanguage: i18n['changeLanguage'];
export const getFixedT: i18n['getFixedT'];
export const t: i18n['t'];
export const exists: i18n['exists'];
export const setDefaultNamespace: i18n['setDefaultNamespace'];
export const hasLoadedNamespace: i18n['hasLoadedNamespace'];
export const loadNamespaces: i18n['loadNamespaces'];
export const loadLanguages: i18n['loadLanguages'];
7 changes: 6 additions & 1 deletion test/typescript/init.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import i18next, { TFunction } from 'i18next';
import i18next, { TFunction, createInstance } from 'i18next';

// i18next.js export default as esm module because the build is apart from commonjs.
i18next.init(
Expand Down Expand Up @@ -475,3 +475,8 @@ i18next.init({
bindI18n: 'languageChanged editorSaved',
},
});

createInstance({
lng: 'en',
fallbackLng: 'en',
});

0 comments on commit e7a9dd4

Please sign in to comment.