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",
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, |
Two-way binding is actually a one way binding with changes synchronized back to the same state
@Component({
template: `<input [(ngModel)]="value">`
// This is syntactic sugar of the following
template: `<input [ngModel]="value" (ngModelChange)="value = $event">`
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 |
type DecoratorFactory<T, D extends Function> = (config: T) => D; | |
type PropertyDecoratorFactory<T> = DecoratorFactory<T, PropertyDecorator>; | |
function extendDecoratorConfig<C>(decoratorFactory: PropertyDecoratorFactory<C>) { | |
return <C_CUSTOM = {}, C_NEW extends C = C>( | |
configFactory: (config: C & C_CUSTOM) => C_NEW, | |
) => (userConfig?: C & C_CUSTOM) => decoratorFactory(configFactory(userConfig)); | |
} | |
function Property(config?: { required?: boolean }): PropertyDecorator { |
// function with branching | |
function giveAppleOrOrange(condition) { | |
if (condition) { | |
return 'apple'; | |
} else { | |
return 'orange'; | |
} | |
} | |
// function without branching |