From 486030d264c099ef84f68ebe45cd975c30c2b149 Mon Sep 17 00:00:00 2001 From: James Nimlos Date: Mon, 25 Mar 2019 09:38:31 -0700 Subject: [PATCH] Update fluent definitions for v0.11 (#33859) * update fluent definitions for v0.11 * remove circular reference * add typescript version requiring fix * downgrade ts version definitelytyped-header-parser errors on prereleases versions but TS v3.4 is not actually released so it also errors --- types/fluent-react/index.d.ts | 4 ++-- types/fluent/fluent-tests.ts | 6 ++++++ types/fluent/index.d.ts | 6 ++++-- types/fluent/tsconfig.json | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/types/fluent-react/index.d.ts b/types/fluent-react/index.d.ts index 5ffc93d874..b3fa7c9dec 100644 --- a/types/fluent-react/index.d.ts +++ b/types/fluent-react/index.d.ts @@ -2,7 +2,7 @@ // Project: http://projectfluent.org // Definitions by: Huy Nguyen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 3.3 import * as React from 'react'; import { @@ -76,7 +76,7 @@ export type Matching = { */ export type Shared< InjectedProps, - DecorationTargetProps extends Shared + DecorationTargetProps > = { [P in Extract]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never; }; diff --git a/types/fluent/fluent-tests.ts b/types/fluent/fluent-tests.ts index d2fcd4a6c4..90b4bffa61 100644 --- a/types/fluent/fluent-tests.ts +++ b/types/fluent/fluent-tests.ts @@ -29,6 +29,7 @@ const bundle4 = new FluentBundle(['en-US'], { // FluentBundle addMessages examples: bundle1.addMessages('foo = Foo'); +bundle2.hasMessage('foo'); bundle2.getMessage('foo'); // FluentBundle addResource examples: @@ -42,3 +43,8 @@ bundle1.addMessages('hello = Hello, { $name }!'); const hello = bundle2.getMessage('hello'); bundle3.format(hello, { name: 'Jane' }, errors2); bundle3.format(hello, undefined, errors2); + +for (const [id, message] of bundle1.messages) { + bundle1.getMessage(id); + bundle1.format(message); +} diff --git a/types/fluent/index.d.ts b/types/fluent/index.d.ts index 56014044ab..8520443354 100644 --- a/types/fluent/index.d.ts +++ b/types/fluent/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for fluent 0.10 +// Type definitions for fluent 0.11 // Project: http://projectfluent.org -// Definitions by: Huy Nguyen +// Definitions by: Huy Nguyen , James Nimlos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -28,6 +28,8 @@ export class FluentResource extends Map { export class FluentBundle { constructor(locales: string | string[], options?: FluentBundleContructorOptions); + messages: IterableIterator<[string, FluentNode[]]>; + hasMessage(source: string): boolean; addMessages(source: string): string[]; getMessage(id: string): FluentNode[]; format(message: FluentNode[], args?: object, errors?: string[]): string; diff --git a/types/fluent/tsconfig.json b/types/fluent/tsconfig.json index 64e2460dcd..c08fe97570 100644 --- a/types/fluent/tsconfig.json +++ b/types/fluent/tsconfig.json @@ -4,6 +4,7 @@ "lib": [ "es6" ], + "target": "es6", "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true,