From 4e575afb73a6dde455a25a2d33fc0f7012ee1351 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Fri, 22 Nov 2019 08:34:20 -0800 Subject: [PATCH] [@types/blessed] Allow additional properties for `IOptions` interface (#40547) * [@types/blessed] Allow additional properties for `IOptions` interface This change allows for arbitrary properties to be stored onto the options object of `Node` instances. This is useful for extra metadata to be stored onto a node and is accessible on the `node.options` property. For example, the `blessed-css` module utilizes the additional properties `id` and `className` for matching CSS selectors: ```typescript const bg = blessed.box({ parent: screen, id: 'bg' }); ``` * Add test * Add to authors --- types/blessed/blessed-tests.ts | 6 ++++++ types/blessed/index.d.ts | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/types/blessed/blessed-tests.ts b/types/blessed/blessed-tests.ts index 00df6dbc7a..7397444388 100644 --- a/types/blessed/blessed-tests.ts +++ b/types/blessed/blessed-tests.ts @@ -53,6 +53,12 @@ screen.key("q", () => screen.destroy()); screen.render(); +// Allow for arbitrary extra properties to be stored in `options` +const extraProps = blessed.box({ + parent: box1, + id: 'box3' +}); + // https://github.com/chjj/blessed/blob/master/test/widget-bigtext.js screen = blessed.screen({ diff --git a/types/blessed/index.d.ts b/types/blessed/index.d.ts index f19ae07465..c4d5cb1d33 100644 --- a/types/blessed/index.d.ts +++ b/types/blessed/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Bryn Austin Bellomy // Steve Kellock // Max Brauer +// Nathan Rajlich // Definitions: https://github.com/borisyankov/DefinitelyTyped // TypeScript Version: 2.1 @@ -595,7 +596,9 @@ export namespace Widgets { destroy(): void; } - interface IOptions {} + interface IOptions { + [name: string]: any; + } interface IHasOptions { options: T;