Skip to content

Commit fd1ac75

Browse files
committed
Fix TS 3.5 compile errors
Fixing errors related to microsoft/TypeScript#31380
1 parent d5fce51 commit fd1ac75

File tree

20 files changed

+40
-41
lines changed

20 files changed

+40
-41
lines changed

extensions/typescript-language-features/src/utils/surveyor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class Survey {
103103
}
104104

105105
private get triggerCount(): number {
106-
const count = this.memento.get(this.triggerCountMementoKey);
106+
const count = this.memento.get<number>(this.triggerCountMementoKey);
107107
return !count || isNaN(+count) ? 0 : +count;
108108
}
109109

src/vs/base/common/objects.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function deepClone<T>(obj: T): T {
1414
return obj as any;
1515
}
1616
const result: any = Array.isArray(obj) ? [] : {};
17-
Object.keys(obj).forEach((key: string) => {
17+
Object.keys(obj as any).forEach((key: string) => {
1818
if (obj[key] && typeof obj[key] === 'object') {
1919
result[key] = deepClone(obj[key]);
2020
} else {

src/vs/base/common/parsers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export abstract class Parser {
7979
this._problemReporter.fatal(message);
8080
}
8181

82-
protected static merge<T>(destination: T, source: T, overwrite: boolean): void {
82+
protected static merge<T extends object>(destination: T, source: T, overwrite: boolean): void {
8383
Object.keys(source).forEach((key: string) => {
8484
const destValue = destination[key];
8585
const sourceValue = source[key];

src/vs/base/node/request.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export function asText(context: IRequestContext): Promise<string | null> {
159159
});
160160
}
161161

162-
export function asJson<T>(context: IRequestContext): Promise<T | null> {
162+
export function asJson<T = {}>(context: IRequestContext): Promise<T | null> {
163163
return new Promise((c, e) => {
164164
if (!isSuccess(context)) {
165165
return e('Server returned ' + context.res.statusCode);

src/vs/base/test/node/config.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ suite('Config', () => {
2020
const newDir = path.join(parentDir, 'config', id);
2121
const testFile = path.join(newDir, 'config.json');
2222

23-
let watcher = new ConfigWatcher(testFile);
23+
let watcher = new ConfigWatcher<{}>(testFile);
2424

2525
let config = watcher.getConfig();
2626
assert.ok(config);

src/vs/editor/contrib/colorPicker/colorDetector.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ export class ColorDetector implements IEditorContribution {
7676
}
7777
const languageId = model.getLanguageIdentifier();
7878
// handle deprecated settings. [languageId].colorDecorators.enable
79-
let deprecatedConfig = this._configurationService.getValue(languageId.language);
79+
const deprecatedConfig = this._configurationService.getValue<{}>(languageId.language);
8080
if (deprecatedConfig) {
81-
let colorDecorators = deprecatedConfig['colorDecorators']; // deprecatedConfig.valueOf('.colorDecorators.enable');
81+
const colorDecorators = deprecatedConfig['colorDecorators']; // deprecatedConfig.valueOf('.colorDecorators.enable');
8282
if (colorDecorators && colorDecorators['enable'] !== undefined && !colorDecorators['enable']) {
8383
return colorDecorators['enable'];
8484
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export class InstantiationService implements IInstantiationService {
220220
// Return a proxy object that's backed by an idle value. That
221221
// strategy is to instantiate services in our idle time or when actually
222222
// needed but not when injected into a consumer
223-
const idle = new IdleValue(() => this._createInstance(ctor, args, _trace));
223+
const idle = new IdleValue(() => this._createInstance<T>(ctor, args, _trace));
224224
return <T>new Proxy(Object.create(null), {
225225
get(_target: T, prop: PropertyKey): any {
226226
return idle.getValue()[prop];

src/vs/workbench/browser/dnd.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { addDisposableListener, EventType } from 'vs/base/browser/dom';
3030
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
3131
import { IRecentFile } from 'vs/platform/history/common/history';
3232
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
33+
import { withNullAsUndefined } from 'vs/base/common/types';
3334

3435
export interface IDraggedResource {
3536
resource: URI;
@@ -81,7 +82,12 @@ export function extractResources(e: DragEvent, externalOnly?: boolean): Array<ID
8182
try {
8283
const draggedEditors: ISerializedDraggedEditor[] = JSON.parse(rawEditorsData);
8384
draggedEditors.forEach(draggedEditor => {
84-
resources.push({ resource: URI.parse(draggedEditor.resource), backupResource: draggedEditor.backupResource ? URI.parse(draggedEditor.backupResource) : undefined, viewState: draggedEditor.viewState, isExternal: false });
85+
resources.push({
86+
resource: URI.parse(draggedEditor.resource),
87+
backupResource: draggedEditor.backupResource ? URI.parse(draggedEditor.backupResource) : undefined,
88+
viewState: withNullAsUndefined(draggedEditor.viewState),
89+
isExternal: false
90+
});
8591
});
8692
} catch (error) {
8793
// Invalid transfer

src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts

+8-15
Original file line numberDiff line numberDiff line change
@@ -388,21 +388,14 @@ export class BreadcrumbsFilePicker extends BreadcrumbsPicker {
388388
const labels = this._instantiationService.createInstance(ResourceLabels, DEFAULT_LABELS_CONTAINER /* TODO@Jo visibility propagation */);
389389
this._disposables.push(labels);
390390

391-
return this._instantiationService.createInstance(
392-
WorkbenchAsyncDataTree,
393-
container,
394-
new FileVirtualDelegate(),
395-
[this._instantiationService.createInstance(FileRenderer, labels)],
396-
this._instantiationService.createInstance(FileDataSource),
397-
{
398-
filterOnType: true,
399-
multipleSelectionSupport: false,
400-
sorter: new FileSorter(),
401-
filter: this._instantiationService.createInstance(FileFilter),
402-
identityProvider: new FileIdentityProvider(),
403-
keyboardNavigationLabelProvider: new FileNavigationLabelProvider()
404-
}
405-
) as WorkbenchAsyncDataTree<BreadcrumbElement, any, FuzzyScore>;
391+
return this._instantiationService.createInstance(WorkbenchAsyncDataTree, container, new FileVirtualDelegate(), [this._instantiationService.createInstance(FileRenderer, labels)], this._instantiationService.createInstance(FileDataSource), {
392+
filterOnType: true,
393+
multipleSelectionSupport: false,
394+
sorter: new FileSorter(),
395+
filter: this._instantiationService.createInstance(FileFilter),
396+
identityProvider: new FileIdentityProvider(),
397+
keyboardNavigationLabelProvider: new FileNavigationLabelProvider()
398+
}) as WorkbenchAsyncDataTree<BreadcrumbElement | IFileStat, any, FuzzyScore>;
406399
}
407400

408401
_setInput(element: BreadcrumbElement): Promise<void> {

src/vs/workbench/browser/parts/editor/editorStatus.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ export class ChangeModeAction extends Action {
10331033
setTimeout(() => {
10341034
this.quickInputService.pick(picks, { placeHolder: nls.localize('pickLanguageToConfigure', "Select Language Mode to Associate with '{0}'", extension || base) }).then(language => {
10351035
if (language) {
1036-
const fileAssociationsConfig = this.configurationService.inspect(FILES_ASSOCIATIONS_CONFIG);
1036+
const fileAssociationsConfig = this.configurationService.inspect<{}>(FILES_ASSOCIATIONS_CONFIG);
10371037

10381038
let associationKey: string;
10391039
if (extension && base[0] !== '.') {

src/vs/workbench/browser/parts/editor/sideBySideEditor.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ export class SideBySideEditor extends BaseEditor {
9393
this.updateStyles();
9494
}
9595

96-
setInput(newInput: SideBySideEditorInput, options: EditorOptions, token: CancellationToken): Promise<void> {
97-
const oldInput = <SideBySideEditorInput>this.input;
96+
setInput(newInput: EditorInput, options: EditorOptions, token: CancellationToken): Promise<void> {
97+
const oldInput = this.input as SideBySideEditorInput;
9898
return super.setInput(newInput, options, token)
99-
.then(() => this.updateInput(oldInput, newInput, options, token));
99+
.then(() => this.updateInput(oldInput, newInput as SideBySideEditorInput, options, token));
100100
}
101101

102102
setOptions(options: EditorOptions): void {

src/vs/workbench/common/editor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ export class SideBySideEditorInput extends EditorInput {
582582
return this.master.revert();
583583
}
584584

585-
getTelemetryDescriptor(): object {
585+
getTelemetryDescriptor(): { [key: string]: unknown } {
586586
const descriptor = this.master.getTelemetryDescriptor();
587587

588588
return assign(descriptor, super.getTelemetryDescriptor());

src/vs/workbench/contrib/debug/electron-browser/debugService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ export class DebugService implements IDebugService {
719719

720720
// If a task is missing the problem matcher the promise will never complete, so we need to have a workaround #35340
721721
let taskStarted = false;
722-
const promise = this.taskService.getActiveTasks().then(tasks => {
722+
const promise: Promise<ITaskSummary | null> = this.taskService.getActiveTasks().then(tasks => {
723723
if (tasks.filter(t => t._id === task._id).length) {
724724
// task is already running - nothing to do.
725725
return Promise.resolve(null);

src/vs/workbench/contrib/output/browser/outputPanel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class OutputPanel extends AbstractTextResourceEditor {
9595
options.renderLineHighlight = 'none';
9696
options.minimap = { enabled: false };
9797

98-
const outputConfig = this.baseConfigurationService.getValue('[Log]');
98+
const outputConfig = this.baseConfigurationService.getValue<{}>('[Log]');
9999
if (outputConfig) {
100100
if (outputConfig['editor.minimap.enabled']) {
101101
options.minimap = { enabled: true };

src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ export class PreferencesEditor extends BaseEditor {
154154
this.preferencesRenderers.editFocusedPreference();
155155
}
156156

157-
setInput(newInput: PreferencesEditorInput, options: SettingsEditorOptions, token: CancellationToken): Promise<void> {
157+
setInput(newInput: EditorInput, options: SettingsEditorOptions, token: CancellationToken): Promise<void> {
158158
this.defaultSettingsEditorContextKey.set(true);
159159
this.defaultSettingsJSONEditorContextKey.set(true);
160160
if (options && options.query) {
161161
this.focusSearch(options.query);
162162
}
163163

164-
return super.setInput(newInput, options, token).then(() => this.updateInput(newInput, options, token));
164+
return super.setInput(newInput, options, token).then(() => this.updateInput(newInput as PreferencesEditorInput, options, token));
165165
}
166166

167167
layout(dimension: DOM.Dimension): void {

src/vs/workbench/contrib/search/browser/searchView.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ export class SearchView extends ViewletPanel {
682682
}));
683683
}
684684

685-
private onContextMenu(e: ITreeContextMenuEvent<RenderableMatch>): void {
685+
private onContextMenu(e: ITreeContextMenuEvent<RenderableMatch | null>): void {
686686
if (!e.element) {
687687
return;
688688
}

src/vs/workbench/contrib/tasks/common/problemMatcher.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ abstract class AbstractLineMatcher implements ILineMatcher {
265265
if (trim) {
266266
value = Strings.trim(value)!;
267267
}
268-
data[property] += endOfLine + value;
268+
(data as any)[property] += endOfLine + value;
269269
}
270270
}
271271

@@ -277,7 +277,7 @@ abstract class AbstractLineMatcher implements ILineMatcher {
277277
if (trim) {
278278
value = Strings.trim(value)!;
279279
}
280-
data[property] = value;
280+
(data as any)[property] = value;
281281
}
282282
}
283283
}
@@ -894,9 +894,9 @@ export class ProblemPatternParser extends Parser {
894894
}
895895

896896
function copyProperty(result: ProblemPattern, source: Config.ProblemPattern, resultKey: keyof ProblemPattern, sourceKey: keyof Config.ProblemPattern) {
897-
let value = source[sourceKey];
897+
const value = source[sourceKey];
898898
if (typeof value === 'number') {
899-
result[resultKey] = value;
899+
(result as any)[resultKey] = value;
900900
}
901901
}
902902
copyProperty(result, value, 'file', 'file');

src/vs/workbench/contrib/welcome/walkThrough/common/walkThroughInput.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class WalkThroughInput extends EditorInput {
8080
return this.options.telemetryFrom;
8181
}
8282

83-
getTelemetryDescriptor(): object {
83+
getTelemetryDescriptor(): { [key: string]: unknown } {
8484
const descriptor = super.getTelemetryDescriptor();
8585
descriptor['target'] = this.getTelemetryFrom();
8686
/* __GDPR__FRAGMENT__

src/vs/workbench/services/extensions/node/extensionPoints.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class ExtensionManifestNLSReplacer extends ExtensionManifestHandler {
251251
* This routine makes the following assumptions:
252252
* The root element is an object literal
253253
*/
254-
private static _replaceNLStrings<T>(nlsConfig: NlsConfiguration, literal: T, messages: { [key: string]: string; }, originalMessages: { [key: string]: string } | null, log: ILog, messageScope: string): void {
254+
private static _replaceNLStrings<T extends object>(nlsConfig: NlsConfiguration, literal: T, messages: { [key: string]: string; }, originalMessages: { [key: string]: string } | null, log: ILog, messageScope: string): void {
255255
function processEntry(obj: any, key: string | number, command?: boolean) {
256256
let value = obj[key];
257257
if (types.isString(value)) {

src/vs/workbench/services/keybinding/common/keybindingEditing.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
210210
private resolveModelReference(): Promise<IReference<IResolvedTextEditorModel>> {
211211
return this.fileService.exists(this.resource)
212212
.then(exists => {
213-
const EOL = this.configurationService.getValue('files', { overrideIdentifier: 'json' })['eol'];
213+
const EOL = this.configurationService.getValue<{}>('files', { overrideIdentifier: 'json' })['eol'];
214214
const result: Promise<any> = exists ? Promise.resolve(null) : this.textFileService.write(this.resource, this.getEmptyContent(EOL), { encoding: 'utf8' });
215215
return result.then(() => this.textModelResolverService.createModelReference(this.resource));
216216
});

0 commit comments

Comments
 (0)