This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type PassengerEnName = { | |
type: 'PassengerEnName'; | |
firstname: string; | |
middlename?: string; | |
lastname: string; | |
}; | |
type PassengerCnName = { | |
type: 'PassengerCnName'; | |
firstname: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ResourcesValue<T> = T extends [] | |
? never | |
: T extends [Resource<infer V>] | |
? [V] | |
: T extends [Resource<infer V>, ...infer Rest] | |
? [V, ...ResourcesValue<Rest>] | |
: never; | |
type InitResource = { | |
init<T>( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const log = (message) => { | |
return { | |
__typename: 'log', | |
message, | |
}; | |
}; | |
const raise = (message) => { | |
return { | |
__typename: 'exception', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pipe<T, A>(a: T[], a1: ListAction<T, A>): A[]; | |
function pipe<T, A, B>(a: T[], a1: ListAction<T, A>, a2: ListAction<A, B>): B[]; | |
function pipe<T, A, B, C>( | |
a: T[], | |
a1: ListAction<T, A>, | |
a2: ListAction<A, B>, | |
a3: ListAction<B, C> | |
): C[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ParseResult = { | |
success: boolean, | |
data: any, | |
source: string | |
} | |
type ParseFailed = { | |
suceess: false, | |
data: any, | |
source: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ToTS<T extends string> = | |
T extends 'Int' | |
? number | |
: T extends 'String' | |
? string | |
: T extends 'Bool' | |
? boolean | |
: never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type GraphQLObject<T extends string> = | |
T extends `\ntype ${infer TypeName} {\n${infer Fields}}\n` | |
? { | |
name: TypeName, | |
fields: { | |
[key in keyof GraphQLObjectFields<Fields>]: GraphQLObjectFields<Fields>[key] | |
} | |
} | |
: never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type NullElement = null | undefined; | |
type BasicElement = number | boolean | string; | |
type ArrayElement = Array<VElement>; | |
type ObjectElement = { | |
props: { | |
children?: ArrayElement; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Renderable = { | |
renderable: true; | |
}; | |
type RenderableVStack = { | |
elems: Renderable[]; | |
} & Renderable; | |
const VStack = (...elems: Renderable[]): RenderableVStack => { | |
return { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type PickKey<T extends Pick<any, any>> = T extends Pick<any, infer K> ? K : never; | |
type EmptySelector<T extends object = any> = { | |
select: <K extends keyof T>(key: K) => NoneEmptySelector<T, Pick<T, K>>; | |
selectAll: () => CompletedSelector<T>; | |
}; | |
type NoneEmptySelector<T extends object = any, P extends Pick<T, any> = any> = { | |
selected: P; | |
select: <K extends Exclude<keyof T, PickKey<P>>>(key: K) => NoneEmptySelector<T, P & Pick<T, K>>; |