@winged/core
Version:
Morden webapp framekwork made only for ts developers. (UNDER DEVELOPMENT, PLEASE DO NOT USE)
44 lines (31 loc) • 1.75 kB
text/typescript
// common types
export type Override<A, B> = {
[K in keyof (A & B)]:
K extends keyof A ? (K extends keyof B ? B[K] : A[K]) : (K extends keyof B ? B[K] : never)
}
/** like override but can only refining/overwrite existing keys, not adding keys */
export type Overwrite<A, B extends A> = { [K in keyof A]: K extends keyof B ? B[K] : A[K]; }
export type Subtract<T1, T2> = Pick<T1, Exclude<keyof T1, keyof T2>>
export interface HashMap<T> { [name: string]: T }
export type BasicType = string | number | boolean
export type OptionalGetters<T> = { [K in keyof T]?: (...args: any[]) => T[K] }
export type Optional<T> = { [K in keyof T]?: T[K] }
// export type Instance<T> = T extends { new(...args: any[]): infer C } ? C : never;
// tslint:disable-next-line:ban-types
export type NonFuncPropNames<T> = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T]
export type NonFuncProps<T> = Pick<T, NonFuncPropNames<T>>
export interface Constructor<T> { new(...args: any[]): T }
// View types
export interface IView {
insertAfter(prevSiblingNode: Node): void
appendTo(container: HTMLElement): void
}
export interface ViewState { [key: string]: BasicType | ViewState[] | ViewState }
export interface StateDependencies { [statePath: string]: StateDependencies }
/** RSD for RenderableStateDescriber */
export interface RSDObject { [key: string]: true | RenderableStateDescriber }
/** RSD for RenderableStateDescriber */
export interface RSDList { [idx: number]: true | RenderableStateDescriber }
export type RenderableStateDescriber = RSDObject | RSDList
/** ModificationTree represents which fields were changed, Empty object represents the whole object changed */
export interface ModificationTree { [mField: string]: ModificationTree }