mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
Update types for lingui__react (#29330)
* Add type for new lingui component * Add test case
This commit is contained in:
committed by
Wesley Wigham
parent
fdba15d53d
commit
2054910ad2
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import { Component, ReactNode } from 'react';
|
||||
import { I18n } from '@lingui/core';
|
||||
|
||||
// tslint:disable-next-line:interface-name
|
||||
export interface I18nComponentProps {
|
||||
children: ({ i18n, i18nHash }: { i18n: I18n, i18nHash?: string }) => ReactNode;
|
||||
update?: boolean;
|
||||
withHash?: boolean;
|
||||
}
|
||||
|
||||
export default class I18nComponent extends Component<I18nComponentProps> {}
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for @lingui/react 2.1
|
||||
// Type definitions for @lingui/react 2.5
|
||||
// Project: https://lingui.github.io/js-lingui/
|
||||
// Definitions by: Jeow Li Huan <https://github.com/huan086>
|
||||
// Definitions: https://github.com/huan086/lingui-typings
|
||||
@@ -9,7 +9,7 @@ import { ComponentClass } from 'react';
|
||||
import { FormatPropsWithoutI18n } from './createFormat';
|
||||
|
||||
export { default as withI18n, withI18nProps } from './withI18n';
|
||||
|
||||
export { default as I18n } from './I18n';
|
||||
export { default as I18nProvider } from './I18nProvider';
|
||||
export { default as Trans } from './Trans';
|
||||
export { Plural, Select, SelectOrdinal } from './Select';
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Catalog, Catalogs, I18n } from '@lingui/core';
|
||||
import {
|
||||
withI18n,
|
||||
I18nProvider,
|
||||
I18n as I18nComponent,
|
||||
Trans,
|
||||
Plural,
|
||||
Select,
|
||||
@@ -42,10 +43,16 @@ const App = () => {
|
||||
const gender = 'male';
|
||||
const price = 21.35;
|
||||
const lastLogin = new Date();
|
||||
const age = 23;
|
||||
return (
|
||||
<I18nProvider language="es" catalogs={catalogs}>
|
||||
<LocalizeAttribute age={23} />
|
||||
<LocalizeOptionAttribute age={23} />
|
||||
<LocalizeAttribute age={age} />
|
||||
<LocalizeOptionAttribute age={age} />
|
||||
<I18nComponent>
|
||||
{({ i18n }) => (
|
||||
<span aria-label={i18n.t('ageId')`${age} years old`}>Attributes</span>
|
||||
)}
|
||||
</I18nComponent>
|
||||
<Trans>Name {name} in <code>Trans</code>.</Trans>
|
||||
<Trans id="transId">Name {name} in <code>Trans</code> with <code>id</code>.</Trans>
|
||||
<Plural id="msg.plural"
|
||||
|
||||
Reference in New Issue
Block a user