This file contains hidden or 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
| let f = x => x |
This file contains hidden or 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
| // assures T is a primitive type | |
| type TPrimitive<T> = | |
| T extends number ? number : | |
| T extends string ? string : | |
| // object, array, etc . . . | |
| // else | |
| never | |
| type Safe<TKind extends string, T> = { | |
| kind: TKind |
This file contains hidden or 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 Url = | |
| Safe<string>({ | |
| validation: [] //fix: introduce validation | |
| validOperations: [getfullPath] | |
| } | |
| */ | |
| // assures T is a primitive type |
This file contains hidden or 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
| import { mapObjIndexed } from 'ramda' | |
| type PropMorphism | |
| <TKeyValue, TContext extends object, TKeyName, TResult> = | |
| (value: TKeyValue, context: TContext, keyname: TKeyName) => | |
| TResult | |
| /** | |
| * Use HasExactlySameKeys if you want to assure to procced |
This file contains hidden or 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
| // Demonstration of Core Concepts | |
| // Event Source Reducer functional style and typesafe | |
| // ========================= | |
| // Lib Event Source | |
| // ========================= | |
| type UserDocument = object | |
| type State = ReadonlyArray<object> |
This file contains hidden or 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
| // ============================================== | |
| // PROPOSAL OF SOLUTION | |
| // ============================================== | |
| // ================================ | |
| // Emulate nominal type-system | |
| // ================================ | |
| type Kind<K> = { kind: K } | |
| type Value<T> = { value: T } |
This file contains hidden or 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
| // ============================================================ | |
| // Sample code: | |
| // Modeling of parametrized Messages and a Generic Dispatcher | |
| // | |
| // Author: @fvilante | |
| // ============================================================ | |
| // Messages (or events, or actions...) |
This file contains hidden or 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
| // A 100% type-safe solution to compose functions in typescript | |
| // tested in TS 3.5.1 | |
| type Func<A, B> = (_: A) => B | |
| class ComposedFn<A, B> { | |
| constructor(private f: Func<A, B>) { } | |
| static of = <A,B>(fn: Func<A, B>): ComposedFn<A, B> => | |
| new ComposedFn(fn) |
This file contains hidden or 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
| interface Entry { | |
| value: string | |
| label: string | |
| } | |
| type Dictionary = Entry[] | |
| const dictionary: Dictionary = [ | |
| { value: 'primeiro', label: '1 - Primeiro' }, | |
| { value: 'segundo', label: '2 - Segundo' }, |
This file contains hidden or 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
| // Don't know why but this seems very impressive to me | |
| type Func<A, B> = (_: A) => B | |
| class Value<A> { | |
| constructor(private _content: A ) { } | |
| static of = <A>(data: A): Value<A> => new Value(data) |