DefinitelyTyped/types/terminal-kit
Louis-Dominique Dubeau 2c58b77f66
[terminal-kit]: fix the typings for Callback and inputField (#42804)
* Fix the typing of Callback.

The previous typing for `Callback` makes no sense. If someone used a callback that had both attributes (which is the most common case), then `err` would be typed as
`undefined` inside the callback. However, whether or not `err` is undefined is not determined by the number of
parameters set on the callback. The previous typing would have been correct if there was a guaranteed that when the
callback has two parameters, the first one is necessarily `undefined`. But there is no such guarantee. If an error
happened, then the first parameter is **not** undefined.

* Fix the return values of inputField.

The Promise was declared to resolve to `boolean` which is absolutely incorrect. `inputField`'s promise resolves to a
string. If cancelation was allowed the user canceled (hit escape), then the final value may be undefined this is true both for the promise and the callback.

* Make the promise mandatory on the return value of inputField.

The promise on the object returned by inputField is always present.

* Fix the return value of inputField to always return a value.

inputField *always* returns an object, *irrespective* of whether a callback is passed. The object is more complex than
currently defined but I only use the `promise` field on it and have no inclination to figure the whole object's
structure. Someone else will have to figure it out.

* Drop the explicit typings on the callback parameters.

They override, and consequently they obscure, the typings that are provided by the definition files.

* Test that abort field is present on return value of inputField.

terminal-kit *always* provides it, callback or no callback.

* The new typings make input be possibly undefined.
2020-03-13 18:48:05 -07:00
..
index.d.ts
Rect.d.ts
ScreenBuffer.d.ts
ScreenBufferHD.d.ts
terminal-kit-tests.ts
Terminal.d.ts
TextBuffer.d.ts
tsconfig.json
tslint.json