qwefgh90 / ng-terminal

NgTerminal is a terminal component on Angular. the Ivy distribution's been released from v5.0.0.
https://qwefgh90.github.io/ng-terminal/
Other
124 stars 27 forks source link

Property 'cursorX' does not exist on type 'IBufferNamespace' #18

Closed hadrien-toma closed 4 years ago

hadrien-toma commented 4 years ago

Description

When I try the example code of the README.md:

export class MyComponent implements AfterViewInit {
    @ViewChild('term', { static: true }) child: NgTerminal;

    constructor() {}

    ngAfterViewInit() {
        this.child.keyEventInput.subscribe((e) => {
            console.log('keyboard event:' + e.domEvent.keyCode + ', ' + e.key);

            const ev = e.domEvent;
            const printable = !ev.altKey && !ev.ctrlKey && !ev.metaKey;

            if (ev.keyCode === 13) {
                this.child.write('\r\n$ ');
            } else if (ev.keyCode === 8) {
                // Do not delete the prompt
                if (this.child.underlying.buffer.cursorX > 2) {
                    this.child.write('\b \b');
                }
            } else if (printable) {
                this.child.write(e.key);
            }
        });
    }
}

Along with:

<ng-terminal
    #term
></ng-terminal>

I get the error:

error TS2339: Property 'cursorX' does not exist on type 'IBufferNamespace'.

35                      if (this.child.underlying.buffer.cursorX > 2) {
                                                         ~~~~~~~

Any idea what I am doing wrong?

Context

My package.json:

{
    "name": "workspace",
    "version": "0.0.0",
    "license": "MIT",
    "scripts": {
        "ng": "ng",
        "nest": "nest",
        "nx": "nx",
        "start": "tools/start/index.bash",
        "front": "tools/start/front/index.bash",
        "back": "tools/start/back/index.bash",
        "back:flask": "tools/start/back/flask/index.bash",
        "back:nest": "tools/start/back/nest/index.bash",
        "dbs": "tools/start/dbs/index.bash",
        "build": "ng build",
        "test": "ng test",
        "lint": "nx workspace-lint && ng lint",
        "e2e": "ng e2e",
        "print-envs": "tools/print-envs/index.bash",
        "configure": "yarn && cd python && pip install --requirement ./requirements.txt",
        "affected:apps": "nx affected:apps",
        "affected:libs": "nx affected:libs",
        "affected:build": "nx affected:build",
        "affected:e2e": "nx affected:e2e",
        "affected:test": "nx affected:test",
        "affected:lint": "nx affected:lint",
        "affected:dep-graph": "nx affected:dep-graph",
        "affected": "nx affected",
        "format": "nx format:write",
        "format:write": "nx format:write",
        "format:check": "nx format:check",
        "update": "ng update @nrwl/workspace",
        "schematic": "nx workspace-schematic",
        "dep-graph": "nx dep-graph",
        "help": "nx help",
        "postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"
    },
    "private": true,
    "dependencies": {
        "@angular/animations": "^9.0.2",
        "@angular/cdk": "^9.1.0",
        "@angular/common": "^9.0.0",
        "@angular/compiler": "^9.0.0",
        "@angular/core": "^9.0.0",
        "@angular/forms": "^9.0.0",
        "@angular/material": "^9.1.0",
        "@angular/platform-browser": "^9.0.0",
        "@angular/platform-browser-dynamic": "^9.0.0",
        "@angular/router": "^9.0.0",
        "@nestjs/common": "^6.8.3",
        "@nestjs/core": "^6.8.3",
        "@nestjs/platform-express": "^6.8.3",
        "@nestjs/swagger": "^4.3.1",
        "@ngrx/effects": "^8.6.0",
        "@ngrx/router-store": "^8.6.0",
        "@ngrx/store": "^8.6.0",
        "@nrwl/angular": "^9.0.3",
        "class-transformer": "^0.2.3",
        "class-validator": "^0.11.0",
        "core-js": "^2.5.4",
        "deep-equal": "^2.0.1",
        "express": "^4.17.1",
        "express-pouchdb": "^4.2.0",
        "faker": "^4.1.0",
        "moment": "^2.24.0",
        "ng-terminal": "^2.4.0",
        "pouchdb": "^7.2.1",
        "reflect-metadata": "^0.1.13",
        "rxjs": "^6.5.0",
        "swagger-ui-express": "^4.1.3",
        "tslib": "^1.10.0",
        "zone.js": "^0.10.2"
    },
    "devDependencies": {
        "@angular-devkit/build-angular": "0.900.1",
        "@angular-devkit/build-ng-packagr": "^0.900.3",
        "@angular-devkit/core": "^9.0.3",
        "@angular-devkit/schematics": "^9.0.3",
        "@angular/cli": "^9.0.1",
        "@angular/compiler-cli": "^9.0.0",
        "@angular/language-service": "^9.0.0",
        "@compodoc/compodoc": "^1.1.11",
        "@nestjs/cli": "^6.14.2",
        "@nestjs/schematics": "^6.7.0",
        "@nestjs/testing": "^6.8.3",
        "@ngrx/schematics": "^8.6.0",
        "@ngrx/store-devtools": "^8.6.0",
        "@nrwl/cypress": "^9.0.3",
        "@nrwl/express": "^9.0.4",
        "@nrwl/jest": "^9.0.3",
        "@nrwl/nest": "^9.0.3",
        "@nrwl/node": "^9.0.3",
        "@nrwl/schematics": "^8.12.7",
        "@nrwl/workspace": "^9.0.3",
        "@schematics/angular": "^9.0.3",
        "@types/deep-equal": "^1.0.1",
        "@types/express": "4.17.0",
        "@types/faker": "^4.1.9",
        "@types/jest": "^24.0.9",
        "@types/json-server": "^0.14.2",
        "@types/node": "^13.7.4",
        "@types/pouchdb": "^6.4.0",
        "chokidar-cli": "^2.1.0",
        "codelyzer": "^5.0.1",
        "cypress": "^3.8.2",
        "dotenv": "^6.2.0",
        "eslint": "^6.1.0",
        "jest": "^24.1.0",
        "jest-preset-angular": "^8.0.0",
        "json-schema-to-typescript": "^8.1.0",
        "ng-packagr": "^9.0.0",
        "pouchdb-server": "^4.2.0",
        "prettier": "^1.18.2",
        "reload": "^3.0.4",
        "ts-jest": "^24.0.0",
        "ts-node": "^8.6.2",
        "tslint": "^5.11.0",
        "typescript": "~3.7.0"
    }
}
hadrien-toma commented 4 years ago

I get it working with this.child.underlying.buffer.active.cursorX > 2 instead of this.child.underlying.buffer.cursorX > 2.

hadrien-toma commented 4 years ago

Do you want me to submit a pull request with the change in the README.md?

qwefgh90 commented 4 years ago

@hadrien-toma Thank you for reporting and It will be great if you submit a pull request with the change.

hadrien-toma commented 4 years ago

Pull request here: #19