Skip to content

Commit e2cf8eb

Browse files
committed
Enable strictBindCallApply for VS Code
Fixes microsoft#64633
1 parent 8b4924d commit e2cf8eb

12 files changed

Lines changed: 17 additions & 16 deletions

File tree

src/tsconfig.base.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"noUnusedLocals": true,
1010
"noImplicitThis": true,
1111
"alwaysStrict": true,
12+
"strictBindCallApply": true,
1213
"baseUrl": ".",
1314
"paths": {
1415
"vs/*": [

src/vs/base/test/common/winjs.promise.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ suite('WinJS and ES6 Promises', function () {
5252
let p1 = winjs.Promise.wrap<number>(new Promise<number>(function (c, e) { c(1); }));
5353
let thenFunc = p1.then.bind(p1);
5454
setTimeout(() => {
55-
thenFunc(() => { });
55+
thenFunc(() => 0);
5656
}, 0);
5757
});
5858

@@ -62,7 +62,7 @@ suite('WinJS and ES6 Promises', function () {
6262
let thenFunc = p1.then.bind(p1);
6363
setTimeout(() => {
6464
c(1);
65-
thenFunc(() => { });
65+
thenFunc(() => 0);
6666
}, 0);
6767
});
6868
});

src/vs/editor/standalone/browser/simpleServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export class StandaloneCommandService implements ICommandService {
242242

243243
try {
244244
this._onWillExecuteCommand.fire({ commandId: id });
245-
const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler].concat(args));
245+
const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler, ...args]) as T;
246246
return Promise.resolve(result);
247247
} catch (err) {
248248
return Promise.reject(err);

src/vs/editor/test/browser/editorTestServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class TestCommandService implements ICommandService {
4444

4545
try {
4646
this._onWillExecuteCommand.fire({ commandId: id });
47-
const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler].concat(args));
47+
const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler, ...args]) as T;
4848
return Promise.resolve(result);
4949
} catch (err) {
5050
return Promise.reject(err);

src/vs/platform/instantiation/common/instantiationService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class InstantiationService implements IInstantiationService {
3737
let _trace = Trace.traceInvocation(fn);
3838
let _done = false;
3939
try {
40-
let accessor = {
40+
const accessor: ServicesAccessor = {
4141
get: <T>(id: ServiceIdentifier<T>, isOptional?: typeof optional) => {
4242

4343
if (_done) {
@@ -51,7 +51,7 @@ export class InstantiationService implements IInstantiationService {
5151
return result;
5252
}
5353
};
54-
return fn.apply(undefined, [accessor].concat(args));
54+
return fn.apply(undefined, [accessor, ...args]);
5555
} finally {
5656
_done = true;
5757
_trace.stop();

src/vs/workbench/api/node/extHost.api.impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function proposedApiFunction<T>(extension: IExtensionDescription, fn: T): T {
7272
if (extension.enableProposedApi) {
7373
return fn;
7474
} else {
75-
return throwProposedApiError.bind(null, extension);
75+
return throwProposedApiError.bind(null, extension) as any as T;
7676
}
7777
}
7878

src/vs/workbench/api/node/extHostFileSystemEventService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
131131

132132
getOnWillRenameFileEvent(extension: IExtensionDescription): Event<vscode.FileWillRenameEvent> {
133133
return (listener, thisArg, disposables) => {
134-
let wrappedListener = <WillRenameListener><any>function () {
135-
listener.apply(thisArg, arguments);
136-
};
134+
const wrappedListener: WillRenameListener = <any>((e: vscode.FileWillRenameEvent) => {
135+
listener.call(thisArg, e);
136+
});
137137
wrappedListener.extension = extension;
138138
return this._onWillRenameFile.event(wrappedListener, undefined, disposables);
139139
};

src/vs/workbench/browser/parts/views/customView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
451451
getOptimalWidth(): number {
452452
if (this.tree) {
453453
const parentNode = this.tree.getHTMLElement();
454-
const childNodes = ([] as Element[]).slice.call(parentNode.querySelectorAll('.outline-item-label > a'));
454+
const childNodes = ([] as HTMLElement[]).slice.call(parentNode.querySelectorAll('.outline-item-label > a'));
455455
return DOM.getLargestChildWidth(parentNode, childNodes);
456456
}
457457
return 0;

src/vs/workbench/node/proxyResolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ function patches(originals: typeof http | typeof https, agent: http.Agent, setti
227227

228228
const config = onRequest && ((<any>options)._vscodeProxySupport || /* LS */ (<any>options)._vscodeSystemProxy) || setting.config;
229229
if (config === 'off') {
230-
return original.apply(null, arguments);
230+
return original.apply(null, arguments as unknown as any[]);
231231
}
232232

233233
if (!options.socketPath && (config === 'override' || config === 'on' && !options.agent) && options.agent !== agent) {
@@ -247,7 +247,7 @@ function patches(originals: typeof http | typeof https, agent: http.Agent, setti
247247
return original(options, callback);
248248
}
249249

250-
return original.apply(null, arguments);
250+
return original.apply(null, arguments as unknown as any[]);
251251
}
252252
return patched;
253253
}

src/vs/workbench/parts/files/electron-browser/views/explorerView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
472472

473473
public getOptimalWidth(): number {
474474
const parentNode = this.explorerViewer.getHTMLElement();
475-
const childNodes = ([] as Element[]).slice.call(parentNode.querySelectorAll('.explorer-item .label-name')); // select all file labels
475+
const childNodes = ([] as HTMLElement[]).slice.call(parentNode.querySelectorAll('.explorer-item .label-name')); // select all file labels
476476

477477
return DOM.getLargestChildWidth(parentNode, childNodes);
478478
}

0 commit comments

Comments
 (0)