diff --git a/src/sql/workbench/browser/editData/editDataInput.ts b/src/sql/workbench/browser/editData/editDataInput.ts index 8907c62d94..706101725b 100644 --- a/src/sql/workbench/browser/editData/editDataInput.ts +++ b/src/sql/workbench/browser/editData/editDataInput.ts @@ -50,7 +50,7 @@ export class EditDataInput extends EditorInput implements IConnectableInput { super(); this._hasBootstrapped = false; this._updateTaskbar = new Emitter(); - this._showResultsEditor = new Emitter(); + this._showResultsEditor = new Emitter(); this._editorInitializing = new Emitter(); this._setup = false; this._stopButtonEnabled = false; @@ -86,7 +86,7 @@ export class EditDataInput extends EditorInput implements IConnectableInput { this._register( this._queryModelService.onEditSessionReady((result) => { if (this.uri === result.ownerUri) { - this._results.editDataGridPanel.onRefreshComplete.then(() => { + this._results.editDataGridPanel!.onRefreshComplete.then(() => { this.initEditEnd(result); }); } @@ -218,7 +218,7 @@ export class EditDataInput extends EditorInput implements IConnectableInput { } public resolve(refresh?: boolean): Promise { return this._sql.resolve(); } - public getEncoding(): string { return this._sql.getEncoding(); } + public getEncoding(): string | undefined { return this._sql.getEncoding(); } public getName(): string { return this._sql.getName(); } public get hasAssociatedFilePath(): boolean { return this._sql.model.hasAssociatedFilePath; } diff --git a/src/sql/workbench/browser/editData/editDataResultsInput.ts b/src/sql/workbench/browser/editData/editDataResultsInput.ts index b2ec6c951c..d69dd4da8d 100644 --- a/src/sql/workbench/browser/editData/editDataResultsInput.ts +++ b/src/sql/workbench/browser/editData/editDataResultsInput.ts @@ -29,7 +29,7 @@ export class EditDataResultsInput extends EditorInput { public readonly onRestoreViewStateEmitter = new Emitter(); public readonly onSaveViewStateEmitter = new Emitter(); - private _editDataGridPanel: IGridPanel; + private _editDataGridPanel?: IGridPanel; constructor(private _uri: string) { super(); @@ -37,11 +37,11 @@ export class EditDataResultsInput extends EditorInput { this._hasBootstrapped = false; } - get editDataGridPanel(): IGridPanel { + get editDataGridPanel(): IGridPanel | undefined { return this._editDataGridPanel; } - set editDataGridPanel(gridPanel: IGridPanel) { + set editDataGridPanel(gridPanel: IGridPanel | undefined) { this._editDataGridPanel = gridPanel; } diff --git a/src/sql/workbench/common/editor/query/queryEditorInput.ts b/src/sql/workbench/common/editor/query/queryEditorInput.ts index da75e991a0..6c89f6bacc 100644 --- a/src/sql/workbench/common/editor/query/queryEditorInput.ts +++ b/src/sql/workbench/common/editor/query/queryEditorInput.ts @@ -120,7 +120,7 @@ export abstract class QueryEditorInput extends EditorInput implements IConnectab public get state(): QueryEditorState { return this._state; } constructor( - private _description: string, + private _description: string | undefined, protected _text: AbstractTextResourceEditorInput, protected _results: QueryResultsInput, @IConnectionManagementService private readonly connectionManagementService: IConnectionManagementService, @@ -173,7 +173,7 @@ export abstract class QueryEditorInput extends EditorInput implements IConnectab public get text(): AbstractTextResourceEditorInput { return this._text; } public get results(): QueryResultsInput { return this._results; } // Description is shown beside the tab name in the combobox of open editors - public getDescription(): string { return this._description; } + public getDescription(): string | undefined { return this._description; } public supportsSplitEditor(): boolean { return false; } public revert(group: GroupIdentifier, options?: IRevertOptions): Promise { return this._text.revert(group, options); diff --git a/src/sql/workbench/common/editor/query/untitledQueryEditorInput.ts b/src/sql/workbench/common/editor/query/untitledQueryEditorInput.ts index 8e6f4d8151..8ca1330a02 100644 --- a/src/sql/workbench/common/editor/query/untitledQueryEditorInput.ts +++ b/src/sql/workbench/common/editor/query/untitledQueryEditorInput.ts @@ -19,7 +19,7 @@ export class UntitledQueryEditorInput extends QueryEditorInput implements IEncod public static readonly ID = 'workbench.editorInput.untitledQueryInput'; constructor( - description: string, + description: string | undefined, text: UntitledTextEditorInput, results: QueryResultsInput, @IConnectionManagementService connectionManagementService: IConnectionManagementService, diff --git a/src/sql/workbench/contrib/editorReplacement/common/editorReplacerContribution.ts b/src/sql/workbench/contrib/editorReplacement/common/editorReplacerContribution.ts index a2fc6388db..aad0c6bda4 100644 --- a/src/sql/workbench/contrib/editorReplacement/common/editorReplacerContribution.ts +++ b/src/sql/workbench/contrib/editorReplacement/common/editorReplacerContribution.ts @@ -17,6 +17,7 @@ import * as path from 'vs/base/common/path'; import { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/services/languageAssociation/common/languageAssociation'; import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput'; import { isThenable } from 'vs/base/common/async'; +import { withNullAsUndefined } from 'vs/base/common/types'; const languageAssociationRegistry = Registry.as(LanguageAssociationExtensions.LanguageAssociations); @@ -44,7 +45,7 @@ export class EditorReplacementContribution implements IWorkbenchContribution { return undefined; } - let language: string; + let language: string | undefined; if (editor instanceof FileEditorInput) { language = editor.getPreferredMode(); } else if (editor instanceof UntitledTextEditorInput) { @@ -52,7 +53,7 @@ export class EditorReplacementContribution implements IWorkbenchContribution { } if (!language) { // in the case the input doesn't have a preferred mode set we will attempt to guess the mode from the file path - language = this.modeService.getModeIdByFilepathOrFirstLine(editor.resource); + language = withNullAsUndefined(this.modeService.getModeIdByFilepathOrFirstLine(editor.resource)); } if (!language) { @@ -66,7 +67,7 @@ export class EditorReplacementContribution implements IWorkbenchContribution { editor.setMode(defaultInputCreator[0]); const newInput = defaultInputCreator[1].convertInput(editor); if (newInput) { - return { override: isThenable(newInput) ? newInput.then(input => this.editorService.openEditor(input, options, group)) : this.editorService.openEditor(newInput, options, group) }; + return { override: isThenable(newInput) ? newInput.then(input => this.editorService.openEditor(input ?? editor, options, group)) : this.editorService.openEditor(newInput, options, group) }; } } } else { @@ -74,7 +75,7 @@ export class EditorReplacementContribution implements IWorkbenchContribution { if (inputCreator) { const newInput = inputCreator.convertInput(editor); if (newInput) { - return { override: isThenable(newInput) ? newInput.then(input => this.editorService.openEditor(input, options, group)) : this.editorService.openEditor(newInput, options, group) }; + return { override: isThenable(newInput) ? newInput.then(input => this.editorService.openEditor(input ?? editor, options, group)) : this.editorService.openEditor(newInput, options, group) }; } } } diff --git a/src/sql/workbench/services/queryEditor/browser/editorDescriptorService.ts b/src/sql/workbench/services/queryEditor/browser/editorDescriptorService.ts index 1c936a4974..77b9ed7365 100644 --- a/src/sql/workbench/services/queryEditor/browser/editorDescriptorService.ts +++ b/src/sql/workbench/services/queryEditor/browser/editorDescriptorService.ts @@ -12,7 +12,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' export interface IEditorDescriptorService { _serviceBrand: undefined; - getEditor(input: EditorInput): IEditorDescriptor; + getEditor(input: EditorInput): IEditorDescriptor | undefined; } export class EditorDescriptorService implements IEditorDescriptorService { @@ -21,7 +21,7 @@ export class EditorDescriptorService implements IEditorDescriptorService { constructor() { } - public getEditor(input: EditorInput): IEditorDescriptor { + public getEditor(input: EditorInput): IEditorDescriptor | undefined { return Registry.as(Extensions.Editors).getEditor(input); } } diff --git a/src/sql/workbench/services/queryEditor/browser/queryEditorService.ts b/src/sql/workbench/services/queryEditor/browser/queryEditorService.ts index 2bda128f89..08012fd4fd 100644 --- a/src/sql/workbench/services/queryEditor/browser/queryEditorService.ts +++ b/src/sql/workbench/services/queryEditor/browser/queryEditorService.ts @@ -53,11 +53,11 @@ export class QueryEditorService implements IQueryEditorService { // Create a sql document pane with accoutrements const fileInput = this._editorService.createEditorInput({ forceUntitled: true, resource: docUri, mode: this._connectionManagementService.getProviderLanguageMode(connectionProviderName) }) as UntitledTextEditorInput; - let untitledEditorModel = await fileInput.resolve() as UntitledTextEditorModel; + let untitledEditorModel = await fileInput.resolve(); if (options.initalContent) { untitledEditorModel.textEditorModel.setValue(options.initalContent); if (options.dirty === false || (options.dirty === undefined && !this._configurationService.getValue('queryEditor').promptToSaveGeneratedFiles)) { - untitledEditorModel.setDirty(false); + (untitledEditorModel as UntitledTextEditorModel).setDirty(false); } } @@ -82,9 +82,9 @@ export class QueryEditorService implements IQueryEditorService { // Create a sql document pane with accoutrements const fileInput = this._editorService.createEditorInput({ forceUntitled: true, resource: docUri, mode: 'sql' }) as UntitledTextEditorInput; - const m = await fileInput.resolve() as UntitledTextEditorModel; + const m = await fileInput.resolve(); //when associatedResource editor is created it is dirty, this must be set to false to be able to detect changes to the editor. - m.setDirty(false); + (m as UntitledTextEditorModel).setDirty(false); // Create an EditDataInput for editing const resultsInput: EditDataResultsInput = this._instantiationService.createInstance(EditDataResultsInput, docUri.toString()); let editDataInput: EditDataInput = this._instantiationService.createInstance(EditDataInput, docUri, schemaName, tableName, fileInput, sqlContent, resultsInput); @@ -94,7 +94,7 @@ export class QueryEditorService implements IQueryEditorService { //Setting the value of the textEditorModel to sqlContent marks editor as dirty, editDataInput handles it. m.textEditorModel.setValue(sqlContent); } - const editor = await this._editorService.openEditor(editDataInput, { pinned: true }); + const editor = (await this._editorService.openEditor(editDataInput, { pinned: true }))!; let params = editor.input as EditDataInput; return params; } diff --git a/src/tsconfig.vscode.json b/src/tsconfig.vscode.json index 0ef9de16a8..ac9bdb344c 100644 --- a/src/tsconfig.vscode.json +++ b/src/tsconfig.vscode.json @@ -70,7 +70,6 @@ "./sql/workbench/contrib/dashboard/**/*.ts", // 1015 errors "./sql/workbench/contrib/dataExplorer/**/*.ts", // 2667 errors "./sql/workbench/contrib/editData/**/*.ts", // 441 errors - "./sql/workbench/contrib/editorReplacement/**/*.ts", // 6 errors "./sql/workbench/contrib/editorReplacement/test/**/*.ts", "./sql/workbench/contrib/jobManagement/**/*.ts", // 315 errors "./sql/workbench/contrib/modelView/**/*.ts", // 2646 errors @@ -92,7 +91,6 @@ "./sql/workbench/services/notebook/**/*.ts", // 200 errors "./sql/workbench/services/objectExplorer/**/*.ts", // 185 errors "./sql/workbench/services/query/test/**/*.ts", - "./sql/workbench/services/queryEditor/**/*.ts", // 10 errors "./sql/workbench/services/queryEditor/test/**/*.ts", "./sql/workbench/test/**/*.ts", // 2975 errors "./sql/workbench/update/**/*.ts", // 2646 errors