Skip to content

Instantly share code, notes, and snippets.

@studioTeaTwo
Created July 24, 2019 06:10
Show Gist options
  • Save studioTeaTwo/cc2eab5df2da82834c5c51a6b3e32880 to your computer and use it in GitHub Desktop.
Save studioTeaTwo/cc2eab5df2da82834c5c51a6b3e32880 to your computer and use it in GitHub Desktop.
// 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