Created
July 25, 2018 08:30
-
-
Save tlaitinen/cdb0be73e96104530c4d9f485ed0b708 to your computer and use it in GitHub Desktop.
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
| function f<A>(k:keyof A) { | |
| return { | |
| setValue: (a:A, v:A[typeof k]) => Object.assign({}, a, {[k]: v}), | |
| getValue: (a:A) => a[k] | |
| }; | |
| } | |
| interface B { | |
| s: string; | |
| n: number; | |
| } | |
| const bs = f<B>('s'); | |
| const bn = f<B>('n'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment