Skip to content

Commit 8fec684

Browse files
committed
docs(types): clarify ExistsFunction note re: narrowing through wrappers
1 parent 61eaf5b commit 8fec684

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

index.d.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,13 @@ export type Callback = (error: any, t: TFunction) => void;
215215
*
216216
* Note: this shape intentionally does not include a type-guard overload so it
217217
* remains easy to assign arrow functions to. The type guard narrowing to
218-
* {@link SelectorKey} is declared directly on `i18n.exists` instead.
219-
* Users who want narrowing on a custom wrapper can type it as
220-
* `typeof i18next.exists`.
218+
* {@link SelectorKey} is declared directly on `i18n.exists` instead. If you
219+
* need narrowing in your own code, call `i18next.exists` directly or forward
220+
* the function by reference (e.g. `const exists: typeof i18next.exists =
221+
* i18next.exists`). Wrapping it in an arrow function will lose the narrowing —
222+
* there is currently no way to keep type-guard narrowing through an
223+
* arrow-function wrapper, which is why `ExistsFunction` deliberately omits the
224+
* predicate overload.
221225
*/
222226
export interface ExistsFunction<
223227
TKeys extends string = string,

0 commit comments

Comments
 (0)