Created
February 3, 2017 19:09
-
-
Save aaronjensen/84d98daddf067781a176590955f258b1 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
export class Endpoint<TResponse> { | |
url: string | |
method: RequestMethod | |
constructor({ url, query = {}, method = 'GET' }: RequestProps) { | |
const qs = queryString.stringify(query) | |
this.url = qs ? `${url}?${qs}` : url | |
this.method = method | |
} | |
} | |
export const getIndustriesRequest: Endpoint<IndustriesResponse> = | |
new Endpoint({ url: industriesUrl() }) | |
export type FetchFulfilledResponse<TResponse> = Exact<{ | |
request: Endpoint<TResponse>, | |
response: TResponse, | |
}> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TypeScript's type system being structural, I think that the only chance to encode phantom types is with "phantom class properties"