From 6bab295572b7e7d61ba9917062d4d8b13cdf1f86 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Fri, 30 Nov 2018 00:13:12 -0500 Subject: [PATCH] Updates to TypeScript 3.2.1 --- package-lock.json | 14 +++++++------- package.json | 4 ++-- src/system/function.ts | 12 ++++++------ src/ui/settings/app.ts | 13 ++++++------- src/ui/shared/app-base.ts | 42 +++++++++++++++--------------------------- src/ui/shared/dom.ts | 4 ++-- ui.tsconfig.json | 7 ++----- 7 files changed, 40 insertions(+), 56 deletions(-) diff --git a/package-lock.json b/package-lock.json index 978a8ee..8549059 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8153,9 +8153,9 @@ "dev": true }, "prettier": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.15.2.tgz", - "integrity": "sha512-YgPLFFA0CdKL4Eg2IHtUSjzj/BWgszDHiNQAe0VAIBse34148whfdzLagRL+QiKS+YfK5ftB6X4v/MBw8yCoug==", + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.15.3.tgz", + "integrity": "sha512-gAU9AGAPMaKb3NNSUUuhhFAS7SCO4ALTN4nRIn6PJ075Qd28Yn2Ig2ahEJWdJwJmlEBTUfC7mMUSFy8MwsOCfg==", "dev": true }, "prettier-tslint": { @@ -8468,7 +8468,7 @@ }, "queue": { "version": "3.1.0", - "resolved": "http://registry.npmjs.org/queue/-/queue-3.1.0.tgz", + "resolved": "https://registry.npmjs.org/queue/-/queue-3.1.0.tgz", "integrity": "sha1-bEnQHwCeIlZ4h4nyv/rGuLmZBYU=", "dev": true, "requires": { @@ -10767,9 +10767,9 @@ "dev": true }, "typescript": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.6.tgz", - "integrity": "sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.1.tgz", + "integrity": "sha512-jw7P2z/h6aPT4AENXDGjcfHTu5CSqzsbZc6YlUIebTyBAq8XaKp78x7VcSh30xwSCcsu5irZkYZUSFP1MrAMbg==", "dev": true }, "uc.micro": { diff --git a/package.json b/package.json index 2f2534b..13e4bfa 100644 --- a/package.json +++ b/package.json @@ -4428,7 +4428,7 @@ "imagemin-webpack-plugin": "2.3.0", "mini-css-extract-plugin": "0.4.4", "node-sass": "4.10.0", - "prettier": "1.15.2", + "prettier": "1.15.3", "prettier-tslint": "0.4.0", "sass-loader": "7.1.0", "terser-webpack-plugin": "1.1.0", @@ -4436,7 +4436,7 @@ "tslint-loader": "3.5.4", "tslint-prettiest": "0.0.1", "ts-loader": "5.3.1", - "typescript": "3.1.6", + "typescript": "3.2.1", "vsce": "1.53.2", "vscode": "1.1.22", "webpack": "4.26.1", diff --git a/src/system/function.ts b/src/system/function.ts index f21151c..3ab2714 100644 --- a/src/system/function.ts +++ b/src/system/function.ts @@ -50,27 +50,27 @@ export namespace Functions { let pending = false; const debounced = _debounce( - (function(this: any) { + (function(this: any, ...args: any[]) { pending = false; - return fn.apply(this, arguments); + return fn.apply(this, args); } as any) as T, wait, options ) as T & IDeferrable; - const tracked = (function(this: any) { + const tracked = (function(this: any, ...args: any[]) { pending = true; - return debounced.apply(this, arguments); + return debounced.apply(this, args); } as any) as T & IDeferrable; tracked.pending = function() { return pending; }; tracked.cancel = function() { - return debounced.cancel.apply(debounced, arguments); + return debounced.cancel.apply(debounced); }; tracked.flush = function(...args: any[]) { - return debounced.flush.apply(debounced, arguments); + return debounced.flush.apply(debounced, args); }; return tracked; diff --git a/src/ui/settings/app.ts b/src/ui/settings/app.ts index 8c72f7d..78aba92 100644 --- a/src/ui/settings/app.ts +++ b/src/ui/settings/app.ts @@ -32,14 +32,13 @@ export class SettingsApp extends App { } protected onBind() { - const onSectionHeaderClicked = this.onSectionHeaderClicked.bind(this); - DOM.listenAll('.section__header', 'click', function(this: HTMLInputElement) { - return onSectionHeaderClicked(this, ...arguments); - }); + const me = this; - const onActionLinkClicked = this.onActionLinkClicked.bind(this); - DOM.listenAll('[data-action]', 'click', function(this: HTMLAnchorElement) { - return onActionLinkClicked(this, ...arguments); + DOM.listenAll('.section__header', 'click', function(this: HTMLInputElement, e: Event) { + return me.onSectionHeaderClicked(this, e as MouseEvent); + }); + DOM.listenAll('[data-action]', 'click', function(this: HTMLAnchorElement, e: Event) { + return me.onActionLinkClicked(this, e as MouseEvent); }); } diff --git a/src/ui/shared/app-base.ts b/src/ui/shared/app-base.ts index e6877e9..0ad946c 100644 --- a/src/ui/shared/app-base.ts +++ b/src/ui/shared/app-base.ts @@ -173,7 +173,7 @@ export abstract class App { el.scrollIntoView({ block: 'start', - behavior: 'instant' + behavior: 'auto' }); window.scrollBy(0, -height); @@ -223,42 +223,30 @@ export abstract class App { private bind() { this.onBind(); - const onMessageReceived = this.onMessageReceived.bind(this); - window.addEventListener('message', onMessageReceived); + window.addEventListener('message', this.onMessageReceived.bind(this)); + + const me = this; - const onInputChecked = this.onInputChecked.bind(this); DOM.listenAll('input[type=checkbox].setting', 'change', function(this: HTMLInputElement) { - return onInputChecked(this, ...arguments); + return me.onInputChecked(this); }); - - const onInputBlurred = this.onInputBlurred.bind(this); DOM.listenAll('input[type=text].setting, input:not([type]).setting', 'blur', function(this: HTMLInputElement) { - return onInputBlurred(this, ...arguments); + return me.onInputBlurred(this); }); - - const onInputFocused = this.onInputFocused.bind(this); DOM.listenAll('input[type=text].setting, input:not([type]).setting', 'focus', function(this: HTMLInputElement) { - return onInputFocused(this, ...arguments); + return me.onInputFocused(this); }); - - const onInputSelected = this.onInputSelected.bind(this); - DOM.listenAll('select.setting', 'change', function(this: HTMLInputElement) { - return onInputSelected(this, ...arguments); + DOM.listenAll('select.setting', 'change', function(this: HTMLSelectElement) { + return me.onInputSelected(this); }); - - const onTokenMouseDown = this.onTokenMouseDown.bind(this); - DOM.listenAll('[data-token]', 'mousedown', function(this: HTMLElement) { - return onTokenMouseDown(this, ...arguments); + DOM.listenAll('[data-token]', 'mousedown', function(this: HTMLElement, e: Event) { + return me.onTokenMouseDown(this, e as MouseEvent); }); - - const onPopupMouseDown = this.onPopupMouseDown.bind(this); - DOM.listenAll('.popup', 'mousedown', function(this: HTMLElement) { - return onPopupMouseDown(this, ...arguments); + DOM.listenAll('.popup', 'mousedown', function(this: HTMLElement, e: Event) { + return me.onPopupMouseDown(this, e as MouseEvent); }); - - const onJumpToLinkClicked = this.onJumpToLinkClicked.bind(this); - DOM.listenAll('a.jump-to[href^="#"]', 'click', function(this: HTMLAnchorElement) { - return onJumpToLinkClicked(this, ...arguments); + DOM.listenAll('a.jump-to[href^="#"]', 'click', function(this: HTMLAnchorElement, e: Event) { + return me.onJumpToLinkClicked(this, e as MouseEvent); }); } diff --git a/src/ui/shared/dom.ts b/src/ui/shared/dom.ts index 1819baa..a629431 100644 --- a/src/ui/shared/dom.ts +++ b/src/ui/shared/dom.ts @@ -35,8 +35,8 @@ export namespace DOM { // return element.querySelectorAll(selectors) as NodeList; // } - export function listenAll(selector: string, name: string, listener: EventListenerOrEventListenerObject) { - const els = document.querySelectorAll(selector); + export function listenAll(selector: string, name: string, listener: EventListener) { + const els = (document.querySelectorAll(selector) as unknown) as Element[]; for (const el of els) { el.addEventListener(name, listener, false); } diff --git a/ui.tsconfig.json b/ui.tsconfig.json index 172ddf6..b6cea4e 100644 --- a/ui.tsconfig.json +++ b/ui.tsconfig.json @@ -1,16 +1,13 @@ { - "version": "2.0.0", - "compileOnSave": false, "compilerOptions": { "forceConsistentCasingInFileNames": true, - "lib": ["es5", "dom", "dom.iterable", "es2015", "es2015.iterable", "es2016"], + "lib": ["dom", "dom.iterable", "es2015", "es2015.iterable", "es2016"], "module": "es2015", "moduleResolution": "node", "noFallthroughCasesInSwitch": true, "noImplicitReturns": true, - "noUnusedLocals": true, + "noUnusedLocals": false, "outDir": "dist/ui", - "removeComments": true, "rootDir": "./src/ui", "skipLibCheck": true, "sourceMap": true,