Created
July 24, 2019 06:10
-
-
Save studioTeaTwo/cc2eab5df2da82834c5c51a6b3e32880 to your computer and use it in GitHub Desktop.
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
// library | |
type TransformFunction = (rawResponse: object) => object; | |
type TransformedEntity<T extends TransformFunction> = ReturnType<T | |
>; | |
// indivisual | |
function transform1(rawResponse: object) { | |
return { | |
keyName1: rawResponse['0'], | |
keyName2: rawResponse['1'], | |
}; | |
} | |
type Entity1 = TransformedEntity<typeof transform1>; | |
const entity1: Entity1 = { | |
a: 'aaa' // type error | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment