Skip to content

Commit b321278

Browse files
committed
Add type definitions for i18n component and v-t directive
1 parent 0df3aa3 commit b321278

File tree

1 file changed

+48
-10
lines changed

1 file changed

+48
-10
lines changed

index.d.ts

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,57 @@
1-
// #region Vue 2
2-
declare module 'vue/types/vue' {
3-
interface Vue {
4-
$t: (key: string, values?: Record<string, unknown>) => string
5-
$ta: (key: string, values?: Record<string, unknown>) => Record<string, string>
1+
import { PropType, DefineComponent, FunctionDirective } from 'vue-demi'
2+
import { FluentVariable } from '@fluent/bundle'
3+
4+
type ComponentType = DefineComponent<{
5+
/**
6+
* The key of the translation.
7+
*/
8+
path: {
9+
type: StringConstructor,
10+
required: true,
11+
},
12+
/**
13+
* Arguments to pass to the translation.
14+
*/
15+
args: {
16+
type: PropType<Record<string, FluentVariable>>,
17+
default: () => Record<string, FluentVariable>,
18+
},
19+
/**
20+
* The tag to use as a root element.
21+
*/
22+
tag: {
23+
type: StringConstructor,
24+
default: 'span',
25+
},
26+
/**
27+
* Whether to render translation as html.
28+
*/
29+
html: {
30+
type: BooleanConstructor,
31+
default: false,
32+
},
33+
/**
34+
* Whether to render translation without a root element.
35+
*/
36+
noTag: {
37+
type: BooleanConstructor,
38+
default: false,
639
}
7-
}
8-
// #endregion
40+
}>
941

10-
// #region Vue 3
11-
declare module '@vue/runtime-core' {
42+
declare module 'vue' {
1243
interface ComponentCustomProperties {
1344
$t: (key: string, values?: Record<string, unknown>) => string
1445
$ta: (key: string, values?: Record<string, unknown>) => Record<string, string>
1546
}
47+
48+
interface ComponentCustomProperties {
49+
vT: FunctionDirective<HTMLElement, Record<string, FluentVariable>>
50+
}
51+
52+
interface GlobalComponents {
53+
i18n: ComponentType
54+
}
1655
}
17-
// #endregion
1856

1957
export * from './dist'

0 commit comments

Comments
 (0)
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