From 01e32f427db9b4214068a79b9e25f8baaf4e755c Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Wed, 12 Jul 2023 07:12:38 +0200 Subject: [PATCH] types: emit function can have additional arguments #1993 --- CHANGELOG.md | 4 ++++ index.d.ts | 2 +- test/typescript/exposed.test.ts | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 175134ad..36f76f42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 23.2.10 + +- types: emit function can have additional arguments [1993](https://github.com/i18next/i18next/issues/1993) + ## 23.2.9 - types: Add brand to TFunction type so different namespaces' TFunctions are not treated as compatible [1994](https://github.com/i18next/i18next/pull/1994) diff --git a/index.d.ts b/index.d.ts index fce6587e..a9a1daf6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1436,7 +1436,7 @@ export interface i18n { /** * Emit event */ - emit(eventName: string): void; + emit(eventName: string, ...args: any[]): void; } declare const i18next: i18n; diff --git a/test/typescript/exposed.test.ts b/test/typescript/exposed.test.ts index 52023ba6..04bd412d 100644 --- a/test/typescript/exposed.test.ts +++ b/test/typescript/exposed.test.ts @@ -25,3 +25,8 @@ formatter!.addCached( 'test', (lng: string | undefined, options: any) => (value: any) => 'formatted', ); + +i18next.on('custom', (arg) => {}); +i18next.emit('custom'); +i18next.emit('custom', { some: 'opt' }); +i18next.emit('custom', { some: 'opt' }, { more: 'stuff' });