[fluent] Add 'undefined' to return type of FluentBundle.getMessage() (#36671)

* Fix(fluent): add 'undefined' to return type of FluentBundle.getMessage().

* Fix(fluent): Change parameter of FluentBundle.hasMessage() to 'id' to match API docs.
This commit is contained in:
Seally 2019-07-11 03:43:04 +07:00 committed by Armando Aguirre
parent b2e1bf8c80
commit ac8a9d309e
2 changed files with 5 additions and 5 deletions

View File

@ -13,7 +13,7 @@ if (errors1.length) {
const welcome = bundle1.getMessage('welcome');
bundle1.format(welcome, { name: 'Anna' });
bundle1.format(welcome || [], { name: 'Anna' });
// FluentBundle constructor examples:
const bundle2 = new FluentBundle(['en-US']);
@ -41,8 +41,8 @@ bundle2.getMessage('foo');
const errors2: Array<string | Error> = [];
bundle1.addMessages('hello = Hello, { $name }!');
const hello = bundle2.getMessage('hello');
bundle3.format(hello, { name: 'Jane' }, errors2);
bundle3.format(hello, undefined, errors2);
bundle3.format(hello || [], { name: 'Jane' }, errors2);
bundle3.format(hello || [], undefined, errors2);
for (const [id, message] of bundle1.messages) {
bundle1.getMessage(id);

View File

@ -30,9 +30,9 @@ export class FluentBundle {
constructor(locales: string | string[], options?: FluentBundleContructorOptions);
locales: string[];
messages: IterableIterator<[string, FluentNode[]]>;
hasMessage(source: string): boolean;
hasMessage(id: string): boolean;
addMessages(source: string): string[];
getMessage(id: string): FluentNode[];
getMessage(id: string): FluentNode[] | undefined;
format(message: FluentNode[], args?: object, errors?: Array<string | Error>): string;
addResource(res: FluentResource): string[];
}