From a7a58aa055202686f0983c8741dfb5a777c900a2 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 17 Sep 2018 13:41:44 -0700 Subject: [PATCH] Enable strict null checks and restrict DOM access in common Part of #1507 Part of #1319 --- package.json | 4 +++- src/common/EventEmitter.ts | 2 +- src/common/tsconfig.json | 18 ++++++++++++++++++ typings/xterm.d.ts | 2 ++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/common/tsconfig.json diff --git a/package.json b/package.json index 4bdac04864..821872bd25 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "start": "node demo/start", "start-zmodem": "node demo/zmodem/app", "lint": "tslint 'src/**/*.ts' './demo/**/*.ts'", + "pretest": "npm run layering", "test": "npm-run-all mocha lint", "test-debug": "node --inspect-brk node_modules/.bin/gulp test", "test-suite": "gulp mocha-suite --test", @@ -64,6 +65,7 @@ "coveralls": "nyc report --reporter=text-lcov | coveralls", "webpack": "gulp webpack", "watch": "concurrently --kill-others-on-fail --names \"lib,css\" \"tsc -w\" \"gulp watch-css\"", - "watch-addons": "concurrently --kill-others-on-fail --names \"attach,fit,fullscreen,search,terminado,webLinks,winptyCompat,zmodem\" \"tsc -w -p ./src/addons/attach\" \"tsc -w -p ./src/addons/fit\" \"tsc -w -p ./src/addons/fullscreen\" \"tsc -w -p ./src/addons/search\" \"tsc -w -p ./src/addons/terminado\" \"tsc -w -p ./src/addons/webLinks\" \"tsc -w -p ./src/addons/winptyCompat\" \"tsc -w -p ./src/addons/zmodem\"" + "watch-addons": "concurrently --kill-others-on-fail --names \"attach,fit,fullscreen,search,terminado,webLinks,winptyCompat,zmodem\" \"tsc -w -p ./src/addons/attach\" \"tsc -w -p ./src/addons/fit\" \"tsc -w -p ./src/addons/fullscreen\" \"tsc -w -p ./src/addons/search\" \"tsc -w -p ./src/addons/terminado\" \"tsc -w -p ./src/addons/webLinks\" \"tsc -w -p ./src/addons/winptyCompat\" \"tsc -w -p ./src/addons/zmodem\"", + "layering": "tsc -p ./src/common" } } diff --git a/src/common/EventEmitter.ts b/src/common/EventEmitter.ts index ae8f0069dc..f9c0c0014e 100644 --- a/src/common/EventEmitter.ts +++ b/src/common/EventEmitter.ts @@ -14,7 +14,7 @@ export class EventEmitter extends Disposable implements IEventEmitter, IDisposab super(); // Restore the previous events if available, this will happen if the // constructor is called multiple times on the same object (terminal reset). - this._events = this._events || {}; + this._events = (this)._events || {}; } public on(type: string, listener: XtermListener): void { diff --git a/src/common/tsconfig.json b/src/common/tsconfig.json new file mode 100644 index 0000000000..34198fdd3c --- /dev/null +++ b/src/common/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "es5" + ], + "rootDir": ".", + "noEmit": true, + "strict": true, + "types": [ + "../../node_modules/@types/mocha", + "../../" + ] + }, + "include": [ + "./**/*" + ] +} diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index cc1ebcd9e3..c82e821ef5 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -7,6 +7,8 @@ * to be stable and consumed by external programs. */ +/// + declare module 'xterm' { /** * A string representing text font weight.