tsc -v 2.4.2
및 노드 v6.10.3 인 TypeScript의 작은 프로젝트를 진행하고 있습니다.TypeScript + NodeJS readline 속성이 누락되었습니다
나는 CLI에서 키 누르기를 캡처하고 싶으므로 import * as readline from 'readline'
을 시도한 다음 readline.emitKeyPressEvents(process.stdin)
을 나중에 사용하지만 the property emitKeyPressEvents is not found on typeof readline
이라고 불평합니다.
나는 또한 npm install --save @types/node
을 작성했습니다.
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