Skip to content

Commit

Permalink
Updates to TypeScript 3.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Nov 30, 2018
1 parent cf795a6 commit 6bab295
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 56 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4428,15 +4428,15 @@
"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",
"tslint": "5.11.0",
"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",
Expand Down
12 changes: 6 additions & 6 deletions src/system/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 6 additions & 7 deletions src/ui/settings/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ export class SettingsApp extends App<SettingsBootstrap> {
}

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);
});
}

Expand Down
42 changes: 15 additions & 27 deletions src/ui/shared/app-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export abstract class App<TBootstrap extends Bootstrap> {

el.scrollIntoView({
block: 'start',
behavior: 'instant'
behavior: 'auto'
});
window.scrollBy(0, -height);

Expand Down Expand Up @@ -223,42 +223,30 @@ export abstract class App<TBootstrap extends Bootstrap> {
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);
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/ui/shared/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export namespace DOM {
// return element.querySelectorAll(selectors) as NodeList<T>;
// }

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);
}
Expand Down
7 changes: 2 additions & 5 deletions ui.tsconfig.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 6bab295

Please sign in to comment.