mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[node/readline] expose line/cursor properties + tests (#40513)
The current "line" and "cursor" states are often necessary when developing applications that use readline for prompts. See https://github.com/nodejs/node/issues/30347
This commit is contained in:
parent
3eea7ab402
commit
141ff986a4
7
types/node/readline.d.ts
vendored
7
types/node/readline.d.ts
vendored
@ -13,6 +13,13 @@ declare module "readline" {
|
||||
class Interface extends events.EventEmitter {
|
||||
readonly terminal: boolean;
|
||||
|
||||
// Need direct access to line/cursor data, for use in external processes
|
||||
// see: https://github.com/nodejs/node/issues/30347
|
||||
/** The current input data */
|
||||
readonly line: string;
|
||||
/** The current cursor position in the input line */
|
||||
readonly cursor: number;
|
||||
|
||||
/**
|
||||
* NOTE: According to the documentation:
|
||||
*
|
||||
|
||||
@ -71,6 +71,17 @@ const rl: readline.ReadLine = readline.createInterface(new stream.Readable());
|
||||
rl.write('asd', key);
|
||||
}
|
||||
|
||||
{
|
||||
const data: string | Buffer = "test";
|
||||
rl.line; // $ExpectType string
|
||||
rl.cursor; // $ExpectType number
|
||||
|
||||
rl.write(data);
|
||||
|
||||
rl.line; // $ExpectType string
|
||||
rl.cursor; // $ExpectType number
|
||||
}
|
||||
|
||||
{
|
||||
const strm: NodeJS.WritableStream = new stream.Writable();
|
||||
const x = 1;
|
||||
|
||||
7
types/node/v10/readline.d.ts
vendored
7
types/node/v10/readline.d.ts
vendored
@ -13,6 +13,13 @@ declare module "readline" {
|
||||
class Interface extends events.EventEmitter {
|
||||
readonly terminal: boolean;
|
||||
|
||||
// Need direct access to line/cursor data, for use in external processes
|
||||
// see: https://github.com/nodejs/node/issues/30347
|
||||
/** The current input data */
|
||||
readonly line: string;
|
||||
/** The current cursor position in the input line */
|
||||
readonly cursor: number;
|
||||
|
||||
/**
|
||||
* NOTE: According to the documentation:
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user