To intercact with with VSCode built-in terminal as your default macos based terminal:
{
"key": "cmd+w",
"command": "workbench.action.terminal.kill",
"when": "terminalFocus"
},
{
"key": "cmd+t",
function* drain<T>(arr: T[]): Generator<T> { | |
let item: T | undefined; | |
while ((item = arr.shift())) { | |
yield item; | |
} | |
} | |
const myArray = [1, 2, 3, 4, 5]; |
// First define standard JS constructor container | |
type Constructable<T> = new (...args: any[]) => T; | |
type ConstructableAbstract<T> = abstract new (...args: any[]) => T; | |
type InferConstructable<T> = | |
T extends Constructable<infer C> ? C : | |
T extends ConstructableAbstract<infer C> ? C : never; | |
// Now let's define visitor interfaces |
type AsFunction<T> = T extends (...args: any) => any ? T : never; | |
type InferConstructor<T> = T extends { constructor: infer C } | |
? AsFunction<C> | |
: () => any; | |
type Constructor<T> = new (...args: Parameters<InferConstructor<T>>) => T; | |
type AbstractConstructor<T> = abstract new ( | |
...args: Parameters<InferConstructor<T>> | |
) => T; |
// Type Utils | |
interface DefaultChecker { | |
__defaultChecker: true; | |
} | |
type Default<T, D> = T | DefaultChecker extends DefaultChecker ? D : T; | |
type MapTo<T, E, M> = T extends E ? M : T; | |
type AsKeyOf<K, T> = K extends keyof T ? K : never; | |
type Observable<T> = {}; |
/** | |
* Simple merge of two types where first `T1` will override second `T2` | |
*/ | |
export type MergeSimple<T1, T2> = T1 & Omit<T2, keyof T1>; | |
/** | |
* Recursive merge of array of types where first types take over the last ones | |
*/ | |
export type Merge<T extends any[]> = MergeRecursive<Head<T>, Tail<T>>; |
To intercact with with VSCode built-in terminal as your default macos based terminal:
{
"key": "cmd+w",
"command": "workbench.action.terminal.kill",
"when": "terminalFocus"
},
{
"key": "cmd+t",
class B { | |
b: string; | |
} | |
class A extends asSingleton({ baseClass: B, ctorArgsFn: () => [] }) { | |
a: number; | |
} | |
class AsyncA extends asSingletonAsync({ | |
baseClass: B, |
import { registerMeta } from './event'; | |
enum EventKind { | |
Open = 'open', | |
} | |
interface EventMetaRegistry { | |
[EventKind.Open]: EventOpenMeta; | |
} |
type GetValTypeIfNot<T, D> = T extends { [k: string]: infer V } ? (V extends D ? never : T) : never; | |
interface IndexableByDeletedProp { | |
__IndexableByDeletedProp: true; | |
} | |
type IndexedBy<TA extends Array<any>, K extends keyof T, T = TA[number]> = { | |
[P in T[K]]: GetValTypeIfNot< | |
{ [PP in keyof T]: T[K] extends P ? T[PP] : IndexableByDeletedProp }, | |
IndexableByDeletedProp |