私はtsc -v 2.4.2
とノードv6.10.3を持つTypeScriptの小さなプロジェクトに取り組んでいます。TypeScript + NodeJS readlineプロパティがありません
私はimport * as readline from 'readline'
を試しましたが、その後readline.emitKeyPressEvents(process.stdin)
を使用しましたが、という文句を言います。
npm install --save @types/node
も行っています。ここで
はM(N)WEです:
import * as readline from "readline";
import {SIGINT} from "constants";
export class InputManager
{
private _currentStates: Array<IKeyEntity>;
private _oldStates: Array<IKeyEntity>;
public constructor()
{
// Throws error, won't compile
readline.emitKeyPressEvents(process.stdin);
}
public handleInput()
{
if (process.stdin.isTTY)
process.stdin.setRawMode(true);
process.stdin.on('keypress', (str: string, key: any) => {
process.stdout.write('Handling keypress ['+str+']');
if (key && key.ctrl && (key.name == 'c' || key.name == 'l'))
{
process.kill(process.pid, SIGINT);
}
});
}
}
'@ types/node @ 8.0.36'は今日リリースされ、' emitKeypressEvents'を含みます。 – Oblosys