From d58f5cac01eb844a2eb77131bf46e9c759ab8e83 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 1 Sep 2018 16:48:28 -0700 Subject: [PATCH] Type Terminal --- demo/client.ts | 22 +++++++++++++++++----- demo/tsconfig.json | 4 ++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/demo/client.ts b/demo/client.ts index e8173513..7911b5ab 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -1,4 +1,13 @@ -import * as Terminal from '../build/xterm'; +/** + * Copyright (c) 2018 The xterm.js authors. All rights reserved. + * @license MIT + * + * This file is the entry point for browserify. + */ + +/// + +import { Terminal } from '../lib/public/Terminal'; import * as attach from '../build/addons/attach/attach'; import * as fit from '../build/addons/fit/fit'; import * as fullscreen from '../build/addons/fullscreen/fullscreen'; @@ -6,13 +15,16 @@ import * as search from '../build/addons/search/search'; import * as webLinks from '../build/addons/webLinks/webLinks'; import * as winptyCompat from '../build/addons/winptyCompat/winptyCompat'; +// Pulling in the module's types relies on the above, it's looks a +// little weird here as we're importing "this" module +import { Terminal as TerminalType } from 'xterm'; + export interface IWindowWithTerminal extends Window { // TODO: Type me - term: any; + term: TerminalType; } declare let window: IWindowWithTerminal; - Terminal.applyAddon(attach); Terminal.applyAddon(fit); Terminal.applyAddon(fullscreen); @@ -166,7 +178,7 @@ function runFakeTerminal(): void { })); } -function initOptions(term: any): void { +function initOptions(term: TerminalType): void { const blacklistedOptions = [ // Internal only options 'cancelEvents', @@ -189,7 +201,7 @@ function initOptions(term: any): void { fontWeightBold: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'], rendererType: ['dom', 'canvas'] }; - const options = Object.keys(term._core.options); + const options = Object.keys((term)._core.options); const booleanOptions = []; const numberOptions = []; options.filter(o => blacklistedOptions.indexOf(o) === -1).forEach(o => { diff --git a/demo/tsconfig.json b/demo/tsconfig.json index 8e72b6dd..2edfe2f7 100644 --- a/demo/tsconfig.json +++ b/demo/tsconfig.json @@ -5,4 +5,8 @@ "rootDir": ".", "sourceMap": true }, + "include": [ + "client.ts", + "../typings/xterm.d.ts" + ] }