tiny-types
Version:
A tiny library that brings Tiny Types to JavaScript and TypeScript
18 lines (17 loc) • 1.18 kB
TypeScript
import { PatternMatcher } from './pattern-matching';
import { ConstructorAbstractOrInstance } from './types';
export declare function match<Output_Type>(_: boolean): {
when: (pattern: boolean, transformation: (_: boolean) => Output_Type) => PatternMatcher<boolean, boolean, boolean, Output_Type>;
};
export declare function match<Output_Type>(_: number): {
when: (pattern: number, transformation: (_: number) => Output_Type) => PatternMatcher<number, number, number, Output_Type>;
};
export declare function match<Output_Type>(_: symbol): {
when: (pattern: symbol, transformation: (_: symbol) => Output_Type) => PatternMatcher<symbol, symbol, symbol, Output_Type>;
};
export declare function match<Output_Type>(_: string): {
when: (pattern: string | RegExp, transformation: (_: string) => Output_Type) => PatternMatcher<string, string | RegExp, string, Output_Type>;
};
export declare function match<Input_Type, Output_Type>(_: Input_Type): {
when: <MT extends Input_Type>(pattern: ConstructorAbstractOrInstance<MT>, transformation: (v: MT) => Output_Type) => PatternMatcher<Input_Type, ConstructorAbstractOrInstance<Input_Type>, Input_Type, Output_Type>;
};