Last active
September 17, 2018 11:21
-
-
Save dewey92/14a14c8795f341c2ee70d3792caca34c to your computer and use it in GitHub Desktop.
Phantom Type Validation
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
| class FormData<T> { | |
| private readonly __data__: T; | |
| constructor(value: any) { } | |
| } | |
| interface Unvalidated { __unval__: never } | |
| interface Validated { __val__: never } | |
| declare function validate(data: FormData<Unvalidated>): FormData<Validated>; | |
| declare function sendToBackend(payload: FormData<Validated>): Promise<any> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment