diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 94d91bd875a..e764fe364c8 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -531,6 +531,7 @@ "./vs/workbench/common/component.ts", "./vs/workbench/common/composite.ts", "./vs/workbench/common/contributions.ts", + "./vs/workbench/common/editor.ts", "./vs/workbench/common/extensionHostProtocol.ts", "./vs/workbench/common/memento.ts", "./vs/workbench/common/notifications.ts", diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index 37bc456e121..523b7150d54 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -19,7 +19,7 @@ import { IEditorGroup } from 'vs/workbench/services/group/common/editorGroupsSer import { ICompositeControl } from 'vs/workbench/common/composite'; import { ActionRunner, IAction } from 'vs/base/common/actions'; -export const ActiveEditorContext = new RawContextKey('activeEditor', null); +export const ActiveEditorContext = new RawContextKey('activeEditor', null); export const EditorsVisibleContext = new RawContextKey('editorIsOpen', false); export const EditorGroupActiveEditorDirtyContext = new RawContextKey('groupActiveEditorDirty', false); export const NoEditorsVisibleContext: ContextKeyExpr = EditorsVisibleContext.toNegated(); @@ -276,7 +276,7 @@ export interface IEditorInput extends IDisposable { /** * Returns the associated resource of this input. */ - getResource(): URI; + getResource(): URI | null; /** * Unique type identifier for this inpput. @@ -286,22 +286,22 @@ export interface IEditorInput extends IDisposable { /** * Returns the display name of this input. */ - getName(): string; + getName(): string | null; /** * Returns the display description of this input. */ - getDescription(verbosity?: Verbosity): string; + getDescription(verbosity?: Verbosity): string | null; /** * Returns the display title of this input. */ - getTitle(verbosity?: Verbosity): string; + getTitle(verbosity?: Verbosity): string | null; /** * Resolves the input. */ - resolve(): Thenable; + resolve(): Thenable; /** * Returns if this input is dirty or not. @@ -344,7 +344,7 @@ export abstract class EditorInput extends Disposable implements IEditorInput { /** * Returns the associated resource of this input if any. */ - getResource(): URI { + getResource(): URI | null { return null; } @@ -352,7 +352,7 @@ export abstract class EditorInput extends Disposable implements IEditorInput { * Returns the name of this input that can be shown to the user. Examples include showing the name of the input * above the editor area when the input is shown. */ - getName(): string { + getName(): string | null { return null; } @@ -360,7 +360,7 @@ export abstract class EditorInput extends Disposable implements IEditorInput { * Returns the description of this input that can be shown to the user. Examples include showing the description of * the input above the editor area to the side of the name of the input. */ - getDescription(verbosity?: Verbosity): string { + getDescription(verbosity?: Verbosity): string | null { return null; } @@ -368,7 +368,7 @@ export abstract class EditorInput extends Disposable implements IEditorInput { * Returns the title of this input that can be shown to the user. Examples include showing the title of * the input above the editor area as hover over the input label. */ - getTitle(verbosity?: Verbosity): string { + getTitle(verbosity?: Verbosity): string | null { return this.getName(); } @@ -376,7 +376,7 @@ export abstract class EditorInput extends Disposable implements IEditorInput { * Returns the preferred editor for this input. A list of candidate editors is passed in that whee registered * for the input. This allows subclasses to decide late which editor to use for the input on a case by case basis. */ - getPreferredEditorId(candidates: string[]): string { + getPreferredEditorId(candidates: string[]): string | null { if (candidates && candidates.length > 0) { return candidates[0]; } @@ -402,7 +402,7 @@ export abstract class EditorInput extends Disposable implements IEditorInput { * Returns a type of EditorModel that represents the resolved input. Subclasses should * override to provide a meaningful model. */ - abstract resolve(): Thenable; + abstract resolve(): Thenable; /** * An editor that is dirty will be asked to be saved once it closes. @@ -585,7 +585,7 @@ export class SideBySideEditorInput extends EditorInput { this._register(this.master.onDidChangeLabel(() => this._onDidChangeLabel.fire())); } - resolve(): Thenable { + resolve(): Thenable { return Promise.resolve(null); } @@ -694,41 +694,41 @@ export class EditorOptions implements IEditorOptions { * Tells the editor to not receive keyboard focus when the editor is being opened. By default, * the editor will receive keyboard focus on open. */ - preserveFocus: boolean; + preserveFocus: boolean | undefined; /** * Tells the editor to reload the editor input in the editor even if it is identical to the one * already showing. By default, the editor will not reload the input if it is identical to the * one showing. */ - forceReload: boolean; + forceReload: boolean | undefined; /** * Will reveal the editor if it is already opened and visible in any of the opened editor groups. */ - revealIfVisible: boolean; + revealIfVisible: boolean | undefined; /** * Will reveal the editor if it is already opened (even when not visible) in any of the opened editor groups. */ - revealIfOpened: boolean; + revealIfOpened: boolean | undefined; /** * An editor that is pinned remains in the editor stack even when another editor is being opened. * An editor that is not pinned will always get replaced by another editor that is not pinned. */ - pinned: boolean; + pinned: boolean | undefined; /** * The index in the document stack where to insert the editor into when opening. */ - index: number; + index: number | undefined; /** * An active editor that is opened will show its contents directly. Set to true to open an editor * in the background. */ - inactive: boolean; + inactive: boolean | undefined; } /** @@ -741,9 +741,9 @@ export class TextEditorOptions extends EditorOptions { private endColumn: number; private revealInCenterIfOutsideViewport: boolean; - private editorViewState: IEditorViewState; + private editorViewState: IEditorViewState | null; - static from(input?: IBaseResourceInput): TextEditorOptions { + static from(input?: IBaseResourceInput): TextEditorOptions | null { if (!input || !input.options) { return null; } @@ -957,7 +957,7 @@ export interface IResourceOptions { filter?: string | string[]; } -export function toResource(editor: IEditorInput, options?: IResourceOptions): URI { +export function toResource(editor: IEditorInput, options?: IResourceOptions): URI | null { if (!editor) { return null; }