-
Notifications
You must be signed in to change notification settings - Fork 397
/
Copy pathindex.d.ts
67 lines (59 loc) · 1.83 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import type { ReactElement, ComponentType, ReactNode } from "react"
import type { MessageDescriptor } from "@lingui/core"
import type { TransRenderProps } from "@lingui/react"
export function t(
literals: TemplateStringsArray | MessageDescriptor,
...placeholders: any[]
): string
export type UnderscoreDigit<T = string> = { [digit: string]: T }
export type ChoiceOptions<T = string> = {
offset?: number
zero?: T
one?: T
few?: T
many?: T
other?: T
} & UnderscoreDigit<T>
export function plural(arg: number | string, options: ChoiceOptions): string
export function selectOrdinal(
arg: number | string,
options: ChoiceOptions
): string
export function select(arg: string, choices: Record<string, string>): string
export function defineMessages<M extends Record<string, MessageDescriptor>>(
messages: M
): M
export function defineMessage(descriptor: MessageDescriptor): MessageDescriptor
export type TransProps = {
id?: string
comment?: string
component?: ReactElement<any, any> | null
render?: (props: TransRenderProps) => ReactElement<any, any> | null
}
export type ChoiceProps = {
value?: string | number
} & TransProps &
ChoiceOptions<ReactNode>
/**
* The types should be changed after this PR is merged
* https://github.com/Microsoft/TypeScript/pull/26797
*
* then we should be able to specify that key of values is same type as value.
* We would be able to remove separate type Values = {...} definition
* eg.
* type SelectProps<Values> = {
* value?: Values
* [key: Values]: string
* }
*
*/
type Values = { [key: string]: string }
export type SelectProps = {
value: string
other: ReactNode
} & TransProps &
Values
export const Trans: ComponentType<TransProps>
export const Plural: ComponentType<ChoiceProps>
export const Select: ComponentType<SelectProps>
export const SelectOrdinal: ComponentType<ChoiceProps>