mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)
* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 * disable strict null check
This commit is contained in:
@@ -9,6 +9,7 @@ import { ServicesAccessor, createDecorator } from 'vs/platform/instantiation/com
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { LinkedList } from 'vs/base/common/linkedList';
|
||||
import { IJSONSchema } from 'vs/base/common/jsonSchema';
|
||||
import { keys } from 'vs/base/common/map';
|
||||
|
||||
export const ICommandService = createDecorator<ICommandService>('commandService');
|
||||
|
||||
@@ -22,9 +23,7 @@ export interface ICommandService {
|
||||
executeCommand<T = any>(commandId: string, ...args: any[]): Promise<T | undefined>;
|
||||
}
|
||||
|
||||
export interface ICommandsMap {
|
||||
[id: string]: ICommand;
|
||||
}
|
||||
export type ICommandsMap = Map<string, ICommand>;
|
||||
|
||||
export interface ICommandHandler {
|
||||
(accessor: ServicesAccessor, ...args: any[]): void;
|
||||
@@ -122,10 +121,13 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR
|
||||
}
|
||||
|
||||
getCommands(): ICommandsMap {
|
||||
const result: ICommandsMap = Object.create(null);
|
||||
this._commands.forEach((value, key) => {
|
||||
result[key] = this.getCommand(key)!;
|
||||
});
|
||||
const result = new Map<string, ICommand>();
|
||||
for (const key of keys(this._commands)) {
|
||||
const command = this.getCommand(key);
|
||||
if (command) {
|
||||
result.set(key, command);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -68,10 +68,10 @@ suite('Command Tests', function () {
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.getCommands()['test'].handler.apply(undefined, [undefined!, 'string']);
|
||||
CommandsRegistry.getCommands()['test2'].handler.apply(undefined, [undefined!, 'string']);
|
||||
assert.throws(() => CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined!, 'string']));
|
||||
assert.equal(CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined!, 1]), true);
|
||||
CommandsRegistry.getCommands().get('test')!.handler.apply(undefined, [undefined!, 'string']);
|
||||
CommandsRegistry.getCommands().get('test2')!.handler.apply(undefined, [undefined!, 'string']);
|
||||
assert.throws(() => CommandsRegistry.getCommands().get('test3')!.handler.apply(undefined, [undefined!, 'string']));
|
||||
assert.equal(CommandsRegistry.getCommands().get('test3')!.handler.apply(undefined, [undefined!, 1]), true);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user