diff --git a/src/vs/editor/contrib/gotoError/gotoErrorWidget.ts b/src/vs/editor/contrib/gotoError/gotoErrorWidget.ts index 89f2f75d243..9da6b13042f 100644 --- a/src/vs/editor/contrib/gotoError/gotoErrorWidget.ts +++ b/src/vs/editor/contrib/gotoError/gotoErrorWidget.ts @@ -228,7 +228,7 @@ export class MarkerNavigationWidget extends PeekViewWidget { protected _fillHead(container: HTMLElement): void { super._fillHead(container); - this._actionbarWidget.push(this.actions, { label: false, icon: true }); + this._actionbarWidget!.push(this.actions, { label: false, icon: true }); } protected _fillTitleIcon(container: HTMLElement): void { diff --git a/src/vs/editor/contrib/referenceSearch/peekViewWidget.ts b/src/vs/editor/contrib/referenceSearch/peekViewWidget.ts index c40368e0311..4dd63cadd03 100644 --- a/src/vs/editor/contrib/referenceSearch/peekViewWidget.ts +++ b/src/vs/editor/contrib/referenceSearch/peekViewWidget.ts @@ -84,12 +84,12 @@ export abstract class PeekViewWidget extends ZoneWidget { private _onDidClose = new Emitter(); - protected _headElement: HTMLDivElement; - protected _primaryHeading: HTMLElement; - protected _secondaryHeading: HTMLElement; - protected _metaHeading: HTMLElement; - protected _actionbarWidget: ActionBar; - protected _bodyElement: HTMLDivElement; + protected _headElement?: HTMLDivElement; + protected _primaryHeading?: HTMLElement; + protected _secondaryHeading?: HTMLElement; + protected _metaHeading?: HTMLElement; + protected _actionbarWidget?: ActionBar; + protected _bodyElement?: HTMLDivElement; constructor(editor: ICodeEditor, options: IPeekViewOptions = {}) { super(editor, options); @@ -139,8 +139,8 @@ export abstract class PeekViewWidget extends ZoneWidget { protected _fillContainer(container: HTMLElement): void { this.setCssClass('peekview-widget'); - this._headElement = dom.$('.head'); - this._bodyElement = dom.$('.body'); + this._headElement = dom.$('.head'); + this._bodyElement = dom.$('.body'); this._fillHead(this._headElement); this._fillBody(this._bodyElement); @@ -151,7 +151,7 @@ export abstract class PeekViewWidget extends ZoneWidget { protected _fillHead(container: HTMLElement): void { const titleElement = dom.$('.peekview-title'); - dom.append(this._headElement, titleElement); + dom.append(this._headElement!, titleElement); dom.addStandardDisposableListener(titleElement, 'click', event => this._onTitleClick(event)); this._fillTitleIcon(titleElement); @@ -161,7 +161,7 @@ export abstract class PeekViewWidget extends ZoneWidget { dom.append(titleElement, this._primaryHeading, this._secondaryHeading, this._metaHeading); const actionsContainer = dom.$('.peekview-actions'); - dom.append(this._headElement, actionsContainer); + dom.append(this._headElement!, actionsContainer); const actionBarOptions = this._getActionBarOptions(); this._actionbarWidget = new ActionBar(actionsContainer, actionBarOptions); @@ -185,20 +185,24 @@ export abstract class PeekViewWidget extends ZoneWidget { } public setTitle(primaryHeading: string, secondaryHeading?: string): void { - this._primaryHeading.innerHTML = strings.escape(primaryHeading); - this._primaryHeading.setAttribute('aria-label', primaryHeading); - if (secondaryHeading) { - this._secondaryHeading.innerHTML = strings.escape(secondaryHeading); - } else { - dom.clearNode(this._secondaryHeading); + if (this._primaryHeading && this._secondaryHeading) { + this._primaryHeading.innerHTML = strings.escape(primaryHeading); + this._primaryHeading.setAttribute('aria-label', primaryHeading); + if (secondaryHeading) { + this._secondaryHeading.innerHTML = strings.escape(secondaryHeading); + } else { + dom.clearNode(this._secondaryHeading); + } } } public setMetaTitle(value: string): void { - if (value) { - this._metaHeading.innerHTML = strings.escape(value); - } else { - dom.clearNode(this._metaHeading); + if (this._metaHeading) { + if (value) { + this._metaHeading.innerHTML = strings.escape(value); + } else { + dom.clearNode(this._metaHeading); + } } } @@ -220,11 +224,15 @@ export abstract class PeekViewWidget extends ZoneWidget { } protected _doLayoutHead(heightInPixel: number, widthInPixel: number): void { - this._headElement.style.height = `${heightInPixel}px`; - this._headElement.style.lineHeight = this._headElement.style.height; + if (this._headElement) { + this._headElement.style.height = `${heightInPixel}px`; + this._headElement.style.lineHeight = this._headElement.style.height; + } } protected _doLayoutBody(heightInPixel: number, widthInPixel: number): void { - this._bodyElement.style.height = `${heightInPixel}px`; + if (this._bodyElement) { + this._bodyElement.style.height = `${heightInPixel}px`; + } } } diff --git a/src/vs/platform/progress/common/progress.ts b/src/vs/platform/progress/common/progress.ts index 117e1af70de..4308c72ce89 100644 --- a/src/vs/platform/progress/common/progress.ts +++ b/src/vs/platform/progress/common/progress.ts @@ -90,13 +90,13 @@ export interface IProgress { export class Progress implements IProgress { private _callback: (data: T) => void; - private _value: T; + private _value?: T; constructor(callback: (data: T) => void) { this._callback = callback; } - get value() { + get value(): T | undefined { return this._value; } diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 25271cbcf99..38ff2ab34d1 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -2786,7 +2786,7 @@ declare module 'vscode' { * *Note* that the eol-sequence will be applied to the * whole document. */ - newEol: EndOfLine; + newEol?: EndOfLine; /** * Create a new TextEdit. diff --git a/src/vs/workbench/api/common/extHostDocumentSaveParticipant.ts b/src/vs/workbench/api/common/extHostDocumentSaveParticipant.ts index ae129051fe8..f55a89b3f30 100644 --- a/src/vs/workbench/api/common/extHostDocumentSaveParticipant.ts +++ b/src/vs/workbench/api/common/extHostDocumentSaveParticipant.ts @@ -153,7 +153,7 @@ export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSavePartic resourceEdit.edits.push({ range: range && Range.from(range), text: newText, - eol: EndOfLine.from(newEol) + eol: newEol && EndOfLine.from(newEol) }); } } diff --git a/src/vs/workbench/api/common/extHostTextEditor.ts b/src/vs/workbench/api/common/extHostTextEditor.ts index fa10d30014b..1e5404bbf2b 100644 --- a/src/vs/workbench/api/common/extHostTextEditor.ts +++ b/src/vs/workbench/api/common/extHostTextEditor.ts @@ -151,11 +151,11 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions { private _proxy: MainThreadTextEditorsShape; private _id: string; - private _tabSize: number; - private _indentSize: number; - private _insertSpaces: boolean; - private _cursorStyle: TextEditorCursorStyle; - private _lineNumbers: TextEditorLineNumbersStyle; + private _tabSize!: number; + private _indentSize!: number; + private _insertSpaces!: boolean; + private _cursorStyle!: TextEditorCursorStyle; + private _lineNumbers!: TextEditorLineNumbersStyle; constructor(proxy: MainThreadTextEditorsShape, id: string, source: IResolvedTextEditorConfiguration) { this._proxy = proxy; diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index 5da072a265e..f7827afe487 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -442,7 +442,7 @@ export namespace TextEdit { export function from(edit: vscode.TextEdit): modes.TextEdit { return { text: edit.newText, - eol: EndOfLine.from(edit.newEol), + eol: edit.newEol && EndOfLine.from(edit.newEol), range: Range.from(edit.range) }; } diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index 9ad1d38f66e..9b0cd9c9cc8 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -514,7 +514,7 @@ export class TextEdit { protected _range: Range; protected _newText: string | null; - protected _newEol: EndOfLine; + protected _newEol?: EndOfLine; get range(): Range { return this._range; @@ -538,11 +538,11 @@ export class TextEdit { this._newText = value; } - get newEol(): EndOfLine { + get newEol(): EndOfLine | undefined { return this._newEol; } - set newEol(value: EndOfLine) { + set newEol(value: EndOfLine | undefined) { if (value && typeof value !== 'number') { throw illegalArgument('newEol'); } @@ -550,7 +550,7 @@ export class TextEdit { } constructor(range: Range, newText: string | null) { - this.range = range; + this._range = range; this._newText = newText; } @@ -798,7 +798,7 @@ export class Location { } uri: URI; - range: Range; + range!: Range; constructor(uri: URI, rangeOrPosition: Range | Position) { this.uri = uri; @@ -861,10 +861,10 @@ export class Diagnostic { range: Range; message: string; - source: string; - code: string | number; severity: DiagnosticSeverity; - relatedInformation: DiagnosticRelatedInformation[]; + source?: string; + code?: string | number; + relatedInformation?: DiagnosticRelatedInformation[]; tags?: DiagnosticTag[]; constructor(range: Range, message: string, severity: DiagnosticSeverity = DiagnosticSeverity.Error) { @@ -989,7 +989,7 @@ export class SymbolInformation { } name: string; - location: Location; + location!: Location; kind: SymbolKind; containerName: string | undefined; @@ -1253,8 +1253,8 @@ export class SignatureInformation { export class SignatureHelp { signatures: SignatureInformation[]; - activeSignature: number; - activeParameter: number; + activeSignature: number = 0; + activeParameter: number = 0; constructor() { this.signatures = []; @@ -1310,19 +1310,19 @@ export enum CompletionItemKind { export class CompletionItem implements vscode.CompletionItem { label: string; - kind: CompletionItemKind | undefined; + kind?: CompletionItemKind; detail?: string; documentation?: string | MarkdownString; sortText?: string; filterText?: string; preselect?: boolean; - insertText: string | SnippetString; + insertText?: string | SnippetString; keepWhitespace?: boolean; - range: Range; + range?: Range; commitCharacters?: string[]; - textEdit: TextEdit; - additionalTextEdits: TextEdit[]; - command: vscode.Command; + textEdit?: TextEdit; + additionalTextEdits?: TextEdit[]; + command?: vscode.Command; constructor(label: string, kind?: CompletionItemKind) { this.label = label; diff --git a/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.ts b/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.ts index 3679e656809..1166da97f9c 100644 --- a/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.ts +++ b/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.ts @@ -386,7 +386,7 @@ export class CallHierarchyTreePeekWidget extends PeekViewWidget { }; this._changeDirectionAction = new ChangeHierarchyDirectionAction(this._direction, changeDirection); this._disposables.add(this._changeDirectionAction); - this._actionbarWidget.push(this._changeDirectionAction, { icon: true, label: false }); + this._actionbarWidget!.push(this._changeDirectionAction, { icon: true, label: false }); } } diff --git a/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts b/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts index 97539eb481f..955579069d7 100644 --- a/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts +++ b/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts @@ -234,7 +234,7 @@ class DirtyDiffWidget extends PeekViewWidget { const changeTypeColor = getChangeTypeColor(this.themeService.getTheme(), changeType); this.style({ frameColor: changeTypeColor, arrowColor: changeTypeColor }); - this._actionbarWidget.context = [this.model.modified!.uri, this.model.changes, index]; + this._actionbarWidget!.context = [this.model.modified!.uri, this.model.changes, index]; this.show(position, height); this.editor.focus(); } @@ -255,11 +255,11 @@ class DirtyDiffWidget extends PeekViewWidget { this._disposables.add(previous); this._disposables.add(next); - this._actionbarWidget.push([previous, next], { label: false, icon: true }); + this._actionbarWidget!.push([previous, next], { label: false, icon: true }); const actions: IAction[] = []; this._disposables.add(createAndFillInActionBarActions(this.menu, { shouldForwardArgs: true }, actions)); - this._actionbarWidget.push(actions, { label: false, icon: true }); + this._actionbarWidget!.push(actions, { label: false, icon: true }); } protected _getActionBarOptions(): IActionBarOptions {