refactoring

This commit is contained in:
Philipp Kühn
2020-10-21 15:30:34 +02:00
parent 020483f0b2
commit 2ebf4bf790
3 changed files with 20 additions and 35 deletions

View File

@@ -113,18 +113,7 @@
// }
// }
export interface Extension {
type: string,
name: string,
options: {
[key: string]: any
},
createCommands(): {
[key: string]: any
},
}
export interface ExtensionSpec<Options, Commands> {
export interface ExtensionSpec<Options = {}, Commands = {}> {
name: string,
defaultOptions?: Options,
createCommands?(this: {
@@ -133,13 +122,18 @@ export interface ExtensionSpec<Options, Commands> {
}): Commands,
}
export type Extension = Required<Omit<ExtensionSpec, 'defaultOptions'> & {
type: string,
options: {
[key: string]: any
},
}>
const defaultExtension: Extension = {
type: 'extension',
name: 'extension',
options: {},
createCommands() {
return {}
},
createCommands: () => ({}),
}
export function createExtension<Options extends {}, Commands extends {}>(config: ExtensionSpec<Options, Commands>) {