提交 1d97b724 编写于 作者: M Matt Bierner

Convert undefined -> null in IOutputService

上级 d58dcf2e
......@@ -38,7 +38,7 @@ export class MainThreadOutputService extends Disposable implements MainThreadOut
const setVisibleChannel = () => {
const panel = this._panelService.getActivePanel();
const visibleChannel: IOutputChannel | null = panel && panel.getId() === OUTPUT_PANEL_ID ? this._outputService.getActiveChannel() : null;
const visibleChannel = panel && panel.getId() === OUTPUT_PANEL_ID ? this._outputService.getActiveChannel() : undefined;
this._proxy.$setVisibleChannel(visibleChannel ? visibleChannel.id : null);
};
this._register(Event.any<any>(this._outputService.onActiveOutputChannel, this._panelService.onDidPanelOpen, this._panelService.onDidPanelClose)(() => setVisibleChannel()));
......@@ -104,7 +104,7 @@ export class MainThreadOutputService extends Disposable implements MainThreadOut
return undefined;
}
private _getChannel(channelId: string): IOutputChannel | null {
private _getChannel(channelId: string): IOutputChannel | undefined {
return this._outputService.getChannel(channelId);
}
}
......@@ -27,7 +27,6 @@ import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IOutputChannelModel, IOutputChannelModelService } from 'vs/workbench/services/output/common/outputChannelModel';
import { withUndefinedAsNull } from 'vs/base/common/types';
const OUTPUT_ACTIVE_CHANNEL_KEY = 'output.activechannel';
......@@ -67,7 +66,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
private channels: Map<string, OutputChannel> = new Map<string, OutputChannel>();
private activeChannelIdInStorage: string;
private activeChannel: OutputChannel | null;
private activeChannel?: OutputChannel;
private readonly _onActiveOutputChannel = new Emitter<string>();
readonly onActiveOutputChannel: Event<string> = this._onActiveOutputChannel.event;
......@@ -106,7 +105,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
// Set active channel to first channel if not set
if (!this.activeChannel) {
const channels = this.getChannelDescriptors();
this.activeChannel = channels && channels.length > 0 ? this.getChannel(channels[0].id) : null;
this.activeChannel = channels && channels.length > 0 ? this.getChannel(channels[0].id) : undefined;
}
this._register(this.lifecycleService.onShutdown(() => this.dispose()));
......@@ -141,15 +140,15 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
return promise.then(() => this._onActiveOutputChannel.fire(id));
}
getChannel(id: string): OutputChannel | null {
return withUndefinedAsNull(this.channels.get(id));
getChannel(id: string): OutputChannel | undefined {
return this.channels.get(id);
}
getChannelDescriptors(): IOutputChannelDescriptor[] {
return Registry.as<IOutputChannelRegistry>(Extensions.OutputChannels).getChannels();
}
getActiveChannel(): IOutputChannel | null {
getActiveChannel(): IOutputChannel | undefined {
return this.activeChannel;
}
......@@ -195,7 +194,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
channel.model.onDispose(() => {
if (this.activeChannel === channel) {
const channels = this.getChannelDescriptors();
const channel = channels.length ? this.getChannel(channels[0].id) : null;
const channel = channels.length ? this.getChannel(channels[0].id) : undefined;
if (channel && this.isPanelShown()) {
this.showChannel(channel.id, true);
} else {
......
......@@ -68,7 +68,7 @@ export interface IOutputService {
* Given the channel id returns the output channel instance.
* Channel should be first registered via OutputChannelRegistry.
*/
getChannel(id: string): IOutputChannel | null;
getChannel(id: string): IOutputChannel | undefined;
/**
* Returns an array of all known output channels descriptors.
......@@ -79,7 +79,7 @@ export interface IOutputService {
* Returns the currently active channel.
* Only one channel can be active at a given moment.
*/
getActiveChannel(): IOutputChannel | null;
getActiveChannel(): IOutputChannel | undefined;
/**
* Show the channel with the passed id.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册