Skip to content

Commit

Permalink
Fix TS 3.5 compile errors
Browse files Browse the repository at this point in the history
Fixing errors related to microsoft/TypeScript#31380
  • Loading branch information
mjbvz committed May 14, 2019
1 parent d5fce51 commit fd1ac75
Show file tree
Hide file tree
Showing 20 changed files with 40 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Survey {
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/common/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function deepClone<T>(obj: T): T {
return obj as any;
}
const result: any = Array.isArray(obj) ? [] : {};
Object.keys(obj).forEach((key: string) => {
Object.keys(obj as any).forEach((key: string) => {
if (obj[key] && typeof obj[key] === 'object') {
result[key] = deepClone(obj[key]);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/common/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export abstract class Parser {
this._problemReporter.fatal(message);
}

protected static merge<T>(destination: T, source: T, overwrite: boolean): void {
protected static merge<T extends object>(destination: T, source: T, overwrite: boolean): void {
Object.keys(source).forEach((key: string) => {
const destValue = destination[key];
const sourceValue = source[key];
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/node/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function asText(context: IRequestContext): Promise<string | null> {
});
}

export function asJson<T>(context: IRequestContext): Promise<T | null> {
export function asJson<T = {}>(context: IRequestContext): Promise<T | null> {
return new Promise((c, e) => {
if (!isSuccess(context)) {
return e('Server returned ' + context.res.statusCode);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/test/node/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ suite('Config', () => {
const newDir = path.join(parentDir, 'config', id);
const testFile = path.join(newDir, 'config.json');

let watcher = new ConfigWatcher(testFile);
let watcher = new ConfigWatcher<{}>(testFile);

let config = watcher.getConfig();
assert.ok(config);
Expand Down
4 changes: 2 additions & 2 deletions src/vs/editor/contrib/colorPicker/colorDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export class ColorDetector implements IEditorContribution {
}
const languageId = model.getLanguageIdentifier();
// handle deprecated settings. [languageId].colorDecorators.enable
let deprecatedConfig = this._configurationService.getValue(languageId.language);
const deprecatedConfig = this._configurationService.getValue<{}>(languageId.language);
if (deprecatedConfig) {
let colorDecorators = deprecatedConfig['colorDecorators']; // deprecatedConfig.valueOf('.colorDecorators.enable');
const colorDecorators = deprecatedConfig['colorDecorators']; // deprecatedConfig.valueOf('.colorDecorators.enable');
if (colorDecorators && colorDecorators['enable'] !== undefined && !colorDecorators['enable']) {
return colorDecorators['enable'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class InstantiationService implements IInstantiationService {
// Return a proxy object that's backed by an idle value. That
// strategy is to instantiate services in our idle time or when actually
// needed but not when injected into a consumer
const idle = new IdleValue(() => this._createInstance(ctor, args, _trace));
const idle = new IdleValue(() => this._createInstance<T>(ctor, args, _trace));
return <T>new Proxy(Object.create(null), {
get(_target: T, prop: PropertyKey): any {
return idle.getValue()[prop];
Expand Down
8 changes: 7 additions & 1 deletion src/vs/workbench/browser/dnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { addDisposableListener, EventType } from 'vs/base/browser/dom';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IRecentFile } from 'vs/platform/history/common/history';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
import { withNullAsUndefined } from 'vs/base/common/types';

export interface IDraggedResource {
resource: URI;
Expand Down Expand Up @@ -81,7 +82,12 @@ export function extractResources(e: DragEvent, externalOnly?: boolean): Array<ID
try {
const draggedEditors: ISerializedDraggedEditor[] = JSON.parse(rawEditorsData);
draggedEditors.forEach(draggedEditor => {
resources.push({ resource: URI.parse(draggedEditor.resource), backupResource: draggedEditor.backupResource ? URI.parse(draggedEditor.backupResource) : undefined, viewState: draggedEditor.viewState, isExternal: false });
resources.push({
resource: URI.parse(draggedEditor.resource),
backupResource: draggedEditor.backupResource ? URI.parse(draggedEditor.backupResource) : undefined,
viewState: withNullAsUndefined(draggedEditor.viewState),
isExternal: false
});
});
} catch (error) {
// Invalid transfer
Expand Down
23 changes: 8 additions & 15 deletions src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,21 +388,14 @@ export class BreadcrumbsFilePicker extends BreadcrumbsPicker {
const labels = this._instantiationService.createInstance(ResourceLabels, DEFAULT_LABELS_CONTAINER /* TODO@Jo visibility propagation */);
this._disposables.push(labels);

return this._instantiationService.createInstance(
WorkbenchAsyncDataTree,
container,
new FileVirtualDelegate(),
[this._instantiationService.createInstance(FileRenderer, labels)],
this._instantiationService.createInstance(FileDataSource),
{
filterOnType: true,
multipleSelectionSupport: false,
sorter: new FileSorter(),
filter: this._instantiationService.createInstance(FileFilter),
identityProvider: new FileIdentityProvider(),
keyboardNavigationLabelProvider: new FileNavigationLabelProvider()
}
) as WorkbenchAsyncDataTree<BreadcrumbElement, any, FuzzyScore>;
return this._instantiationService.createInstance(WorkbenchAsyncDataTree, container, new FileVirtualDelegate(), [this._instantiationService.createInstance(FileRenderer, labels)], this._instantiationService.createInstance(FileDataSource), {
filterOnType: true,
multipleSelectionSupport: false,
sorter: new FileSorter(),
filter: this._instantiationService.createInstance(FileFilter),
identityProvider: new FileIdentityProvider(),
keyboardNavigationLabelProvider: new FileNavigationLabelProvider()
}) as WorkbenchAsyncDataTree<BreadcrumbElement | IFileStat, any, FuzzyScore>;
}

_setInput(element: BreadcrumbElement): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/parts/editor/editorStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ export class ChangeModeAction extends Action {
setTimeout(() => {
this.quickInputService.pick(picks, { placeHolder: nls.localize('pickLanguageToConfigure', "Select Language Mode to Associate with '{0}'", extension || base) }).then(language => {
if (language) {
const fileAssociationsConfig = this.configurationService.inspect(FILES_ASSOCIATIONS_CONFIG);
const fileAssociationsConfig = this.configurationService.inspect<{}>(FILES_ASSOCIATIONS_CONFIG);

let associationKey: string;
if (extension && base[0] !== '.') {
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/browser/parts/editor/sideBySideEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ export class SideBySideEditor extends BaseEditor {
this.updateStyles();
}

setInput(newInput: SideBySideEditorInput, options: EditorOptions, token: CancellationToken): Promise<void> {
const oldInput = <SideBySideEditorInput>this.input;
setInput(newInput: EditorInput, options: EditorOptions, token: CancellationToken): Promise<void> {
const oldInput = this.input as SideBySideEditorInput;
return super.setInput(newInput, options, token)
.then(() => this.updateInput(oldInput, newInput, options, token));
.then(() => this.updateInput(oldInput, newInput as SideBySideEditorInput, options, token));
}

setOptions(options: EditorOptions): void {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/common/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ export class SideBySideEditorInput extends EditorInput {
return this.master.revert();
}

getTelemetryDescriptor(): object {
getTelemetryDescriptor(): { [key: string]: unknown } {
const descriptor = this.master.getTelemetryDescriptor();

return assign(descriptor, super.getTelemetryDescriptor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ export class DebugService implements IDebugService {

// If a task is missing the problem matcher the promise will never complete, so we need to have a workaround #35340
let taskStarted = false;
const promise = this.taskService.getActiveTasks().then(tasks => {
const promise: Promise<ITaskSummary | null> = this.taskService.getActiveTasks().then(tasks => {
if (tasks.filter(t => t._id === task._id).length) {
// task is already running - nothing to do.
return Promise.resolve(null);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/output/browser/outputPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class OutputPanel extends AbstractTextResourceEditor {
options.renderLineHighlight = 'none';
options.minimap = { enabled: false };

const outputConfig = this.baseConfigurationService.getValue('[Log]');
const outputConfig = this.baseConfigurationService.getValue<{}>('[Log]');
if (outputConfig) {
if (outputConfig['editor.minimap.enabled']) {
options.minimap = { enabled: true };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ export class PreferencesEditor extends BaseEditor {
this.preferencesRenderers.editFocusedPreference();
}

setInput(newInput: PreferencesEditorInput, options: SettingsEditorOptions, token: CancellationToken): Promise<void> {
setInput(newInput: EditorInput, options: SettingsEditorOptions, token: CancellationToken): Promise<void> {
this.defaultSettingsEditorContextKey.set(true);
this.defaultSettingsJSONEditorContextKey.set(true);
if (options && options.query) {
this.focusSearch(options.query);
}

return super.setInput(newInput, options, token).then(() => this.updateInput(newInput, options, token));
return super.setInput(newInput, options, token).then(() => this.updateInput(newInput as PreferencesEditorInput, options, token));
}

layout(dimension: DOM.Dimension): void {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/search/browser/searchView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ export class SearchView extends ViewletPanel {
}));
}

private onContextMenu(e: ITreeContextMenuEvent<RenderableMatch>): void {
private onContextMenu(e: ITreeContextMenuEvent<RenderableMatch | null>): void {
if (!e.element) {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/contrib/tasks/common/problemMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ abstract class AbstractLineMatcher implements ILineMatcher {
if (trim) {
value = Strings.trim(value)!;
}
data[property] += endOfLine + value;
(data as any)[property] += endOfLine + value;
}
}

Expand All @@ -277,7 +277,7 @@ abstract class AbstractLineMatcher implements ILineMatcher {
if (trim) {
value = Strings.trim(value)!;
}
data[property] = value;
(data as any)[property] = value;
}
}
}
Expand Down Expand Up @@ -894,9 +894,9 @@ export class ProblemPatternParser extends Parser {
}

function copyProperty(result: ProblemPattern, source: Config.ProblemPattern, resultKey: keyof ProblemPattern, sourceKey: keyof Config.ProblemPattern) {
let value = source[sourceKey];
const value = source[sourceKey];
if (typeof value === 'number') {
result[resultKey] = value;
(result as any)[resultKey] = value;
}
}
copyProperty(result, value, 'file', 'file');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class WalkThroughInput extends EditorInput {
return this.options.telemetryFrom;
}

getTelemetryDescriptor(): object {
getTelemetryDescriptor(): { [key: string]: unknown } {
const descriptor = super.getTelemetryDescriptor();
descriptor['target'] = this.getTelemetryFrom();
/* __GDPR__FRAGMENT__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class ExtensionManifestNLSReplacer extends ExtensionManifestHandler {
* This routine makes the following assumptions:
* The root element is an object literal
*/
private static _replaceNLStrings<T>(nlsConfig: NlsConfiguration, literal: T, messages: { [key: string]: string; }, originalMessages: { [key: string]: string } | null, log: ILog, messageScope: string): void {
private static _replaceNLStrings<T extends object>(nlsConfig: NlsConfiguration, literal: T, messages: { [key: string]: string; }, originalMessages: { [key: string]: string } | null, log: ILog, messageScope: string): void {
function processEntry(obj: any, key: string | number, command?: boolean) {
let value = obj[key];
if (types.isString(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
private resolveModelReference(): Promise<IReference<IResolvedTextEditorModel>> {
return this.fileService.exists(this.resource)
.then(exists => {
const EOL = this.configurationService.getValue('files', { overrideIdentifier: 'json' })['eol'];
const EOL = this.configurationService.getValue<{}>('files', { overrideIdentifier: 'json' })['eol'];
const result: Promise<any> = exists ? Promise.resolve(null) : this.textFileService.write(this.resource, this.getEmptyContent(EOL), { encoding: 'utf8' });
return result.then(() => this.textModelResolverService.createModelReference(this.resource));
});
Expand Down

0 comments on commit fd1ac75

Please sign in to comment.