mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 03:54:24 +01:00
Fixing more strict null errros in extHost and related files
This commit is contained in:
@@ -27,7 +27,7 @@ import { generateUuid } from 'vs/base/common/uuid';
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
export interface ICommandsExecutor {
|
||||
executeCommand<T>(id: string, ...args: any[]): Promise<T>;
|
||||
executeCommand<T>(id: string, ...args: any[]): Promise<T | undefined>;
|
||||
}
|
||||
|
||||
function adjustHandler(handler: (executor: ICommandsExecutor, ...args: any[]) => any): ICommandHandler {
|
||||
@@ -84,8 +84,8 @@ CommandsRegistry.registerCommand(DiffAPICommand.ID, adjustHandler(DiffAPICommand
|
||||
export class OpenAPICommand {
|
||||
public static ID = 'vscode.open';
|
||||
public static execute(executor: ICommandsExecutor, resource: URI, columnOrOptions?: vscode.ViewColumn | vscode.TextDocumentShowOptions, label?: string): Promise<any> {
|
||||
let options: ITextEditorOptions;
|
||||
let position: EditorViewColumn;
|
||||
let options: ITextEditorOptions | undefined;
|
||||
let position: EditorViewColumn | undefined;
|
||||
|
||||
if (columnOrOptions) {
|
||||
if (typeof columnOrOptions === 'number') {
|
||||
|
||||
@@ -102,7 +102,7 @@ export interface MainThreadClipboardShape extends IDisposable {
|
||||
export interface MainThreadCommandsShape extends IDisposable {
|
||||
$registerCommand(id: string): void;
|
||||
$unregisterCommand(id: string): void;
|
||||
$executeCommand<T>(id: string, args: any[]): Promise<T>;
|
||||
$executeCommand<T>(id: string, args: any[]): Promise<T | undefined>;
|
||||
$getCommands(): Promise<string[]>;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
|
||||
private readonly _proxy: MainThreadConfigurationShape;
|
||||
private readonly _extHostWorkspace: ExtHostWorkspace;
|
||||
private readonly _barrier: Barrier;
|
||||
private _actual: ExtHostConfigProvider;
|
||||
private _actual: ExtHostConfigProvider | null;
|
||||
|
||||
constructor(proxy: MainThreadConfigurationShape, extHostWorkspace: ExtHostWorkspace) {
|
||||
this._proxy = proxy;
|
||||
@@ -53,7 +53,7 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
|
||||
}
|
||||
|
||||
public getConfigProvider(): Promise<ExtHostConfigProvider> {
|
||||
return this._barrier.wait().then(_ => this._actual);
|
||||
return this._barrier.wait().then(_ => this._actual!);
|
||||
}
|
||||
|
||||
$initializeConfiguration(data: IConfigurationInitData): void {
|
||||
@@ -93,14 +93,14 @@ export class ExtHostConfigProvider {
|
||||
|
||||
getConfiguration(section?: string, resource?: URI, extensionId?: ExtensionIdentifier): vscode.WorkspaceConfiguration {
|
||||
const config = this._toReadonlyValue(section
|
||||
? lookUp(this._configuration.getValue(null, { resource }, this._extHostWorkspace.workspace), section)
|
||||
: this._configuration.getValue(null, { resource }, this._extHostWorkspace.workspace));
|
||||
? lookUp(this._configuration.getValue(undefined, { resource }, this._extHostWorkspace.workspace), section)
|
||||
: this._configuration.getValue(undefined, { resource }, this._extHostWorkspace.workspace));
|
||||
|
||||
if (section) {
|
||||
this._validateConfigurationAccess(section, resource, extensionId);
|
||||
}
|
||||
|
||||
function parseConfigurationTarget(arg: boolean | ExtHostConfigurationTarget): ConfigurationTarget {
|
||||
function parseConfigurationTarget(arg: boolean | ExtHostConfigurationTarget): ConfigurationTarget | null {
|
||||
if (arg === undefined || arg === null) {
|
||||
return null;
|
||||
}
|
||||
@@ -218,7 +218,7 @@ export class ExtHostConfigProvider {
|
||||
return readonlyProxy(result);
|
||||
}
|
||||
|
||||
private _validateConfigurationAccess(key: string, resource: URI, extensionId: ExtensionIdentifier): void {
|
||||
private _validateConfigurationAccess(key: string, resource: URI | undefined, extensionId: ExtensionIdentifier): void {
|
||||
const scope = OVERRIDE_PROPERTY_PATTERN.test(key) ? ConfigurationScope.RESOURCE : this._configurationScopes[key];
|
||||
const extensionIdText = extensionId ? `[${extensionId.value}] ` : '';
|
||||
if (ConfigurationScope.RESOURCE === scope) {
|
||||
|
||||
@@ -163,7 +163,7 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
|
||||
bucket.push(wrappedThenable);
|
||||
}
|
||||
};
|
||||
}).then(() => {
|
||||
}).then((): any => {
|
||||
if (edits.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export class ExtHostMessageService {
|
||||
commands.push({ title: command, handle, isCloseAffordance: false });
|
||||
} else if (typeof command === 'object') {
|
||||
let { title, isCloseAffordance } = command;
|
||||
commands.push({ title, isCloseAffordance, handle });
|
||||
commands.push({ title, isCloseAffordance: !!isCloseAffordance, handle });
|
||||
} else {
|
||||
console.warn('Invalid message item:', command);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export class ExtHostStorage implements ExtHostStorageShape {
|
||||
this._proxy = mainContext.getProxy(MainContext.MainThreadStorage);
|
||||
}
|
||||
|
||||
getValue<T>(shared: boolean, key: string, defaultValue?: T): Promise<T> {
|
||||
getValue<T>(shared: boolean, key: string, defaultValue?: T): Promise<T | undefined> {
|
||||
return this._proxy.$getValue<T>(shared, key).then(value => value || defaultValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel {
|
||||
private readonly _proxy: MainThreadWebviewsShape;
|
||||
private readonly _viewType: string;
|
||||
private _title: string;
|
||||
private _iconPath: IconPath;
|
||||
private _iconPath?: IconPath;
|
||||
|
||||
private readonly _options: vscode.WebviewPanelOptions;
|
||||
private readonly _webview: ExtHostWebview;
|
||||
|
||||
Reference in New Issue
Block a user