[@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
This commit is contained in:
Nathan Rajlich
2019-11-22 08:34:20 -08:00
committed by Sheetal Nandi
parent 8b1def9e99
commit 4e575afb73
2 changed files with 10 additions and 1 deletions

View File

@@ -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({

View File

@@ -3,6 +3,7 @@
// Definitions by: Bryn Austin Bellomy <https://github.com/brynbellomy>
// Steve Kellock <https://github.com/skellock>
// Max Brauer <https://github.com/mamachanko>
// Nathan Rajlich <https://github.com/TooTallNate>
// 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<T extends IOptions> {
options: T;