From b32127827fd9f2c6004b9f7da8e63463d61e8e83 Mon Sep 17 00:00:00 2001 From: Ivan Demchuk Date: Thu, 15 Jun 2023 13:18:23 +0300 Subject: [PATCH] Add type definitions for `i18n` component and `v-t` directive --- index.d.ts | 58 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/index.d.ts b/index.d.ts index 9dbb0ed8..0792e5fa 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,19 +1,57 @@ -// #region Vue 2 -declare module 'vue/types/vue' { - interface Vue { - $t: (key: string, values?: Record) => string - $ta: (key: string, values?: Record) => Record +import { PropType, DefineComponent, FunctionDirective } from 'vue-demi' +import { FluentVariable } from '@fluent/bundle' + +type ComponentType = DefineComponent<{ + /** + * The key of the translation. + */ + path: { + type: StringConstructor, + required: true, + }, + /** + * Arguments to pass to the translation. + */ + args: { + type: PropType>, + default: () => Record, + }, + /** + * The tag to use as a root element. + */ + tag: { + type: StringConstructor, + default: 'span', + }, + /** + * Whether to render translation as html. + */ + html: { + type: BooleanConstructor, + default: false, + }, + /** + * Whether to render translation without a root element. + */ + noTag: { + type: BooleanConstructor, + default: false, } -} -// #endregion +}> -// #region Vue 3 -declare module '@vue/runtime-core' { +declare module 'vue' { interface ComponentCustomProperties { $t: (key: string, values?: Record) => string $ta: (key: string, values?: Record) => Record } + + interface ComponentCustomProperties { + vT: FunctionDirective> + } + + interface GlobalComponents { + i18n: ComponentType + } } -// #endregion export * from './dist' pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy