diff --git a/types/node/readline.d.ts b/types/node/readline.d.ts index 6cb572e3136dd8..861606986f38de 100644 --- a/types/node/readline.d.ts +++ b/types/node/readline.d.ts @@ -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: * diff --git a/types/node/test/readline.ts b/types/node/test/readline.ts index 36884df6f3981a..664b6b7de21489 100644 --- a/types/node/test/readline.ts +++ b/types/node/test/readline.ts @@ -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; diff --git a/types/node/v10/readline.d.ts b/types/node/v10/readline.d.ts index 9c25da49827f76..102532830e8e23 100644 --- a/types/node/v10/readline.d.ts +++ b/types/node/v10/readline.d.ts @@ -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: *