mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[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:
parent
b2e1bf8c80
commit
ac8a9d309e
@ -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);
|
||||
|
||||
4
types/fluent/index.d.ts
vendored
4
types/fluent/index.d.ts
vendored
@ -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[];
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user