Skip to content

Commit

Permalink
Add store events to typings (#1451)
Browse files Browse the repository at this point in the history
* Fix typings

* Store events typescript test

* Simplify index.d.ts
  • Loading branch information
stmegabit committed May 22, 2020
1 parent d27fa55 commit 075aa62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,14 @@ export interface Interpolator {

export class ResourceStore {
constructor(data: Resource, options: InitOptions);

public data: Resource;
public options: InitOptions;

/**
* Gets fired when resources got added or removed
*/
on(event: 'added' | 'removed', callback: (lng: string, ns: string) => void): void;
}

export interface Services {
Expand Down Expand Up @@ -826,6 +832,11 @@ export interface i18n {
*/
services: Services;

/**
* Internal container for translation resources
*/
store: ResourceStore;

/**
* Uses similar args as the t function and returns true if a key exists.
*/
Expand Down
3 changes: 3 additions & 0 deletions test/typescript/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ i18next.on('removed', (lng: string, ns: string) => {});
i18next.on('languageChanged', (lng: string) => {});
i18next.on('customEvent', () => {});

i18next.store.on('added', (lng: string, ns: string) => {});
i18next.store.on('removed', (lng: string, ns: string) => {});

i18next.getResource('en', 'test', 'key');
i18next.getResource('en', 'test', 'key', { keySeparator: '-' });

Expand Down

0 comments on commit 075aa62

Please sign in to comment.