This repository was archived by the owner on Apr 12, 2026. It is now read-only.
Conversation
dherges
marked this pull request as ready for review
February 18, 2019 06:25
dherges
commented
Feb 18, 2019
| * constructor(private api: ApiClient) | ||
| * | ||
| * fetchNextPage(res: Respurce<Entity>) { | ||
| * return this.api.call(res).get('next').send<>(); |
Contributor
Author
There was a problem hiding this comment.
This is a weak link in the Call api. From <R>send(), you always get a Call<R> with a Resource<R>. What about Call<R, D> to get a R extends Resource<D>?
I think we need:
call()w/o generics to get an any-typedResource<any><R>call()w/ generic type to get anR extends Resource<?>
Thus, the Call<R extends Resource<?>> call class would work with Resource....
Contributor
Author
There was a problem hiding this comment.
export class Call2<R> {
constructor(
public resource: R & ResourceMetadata
) {}
// PROBLEM: only one of the method declaration overrides seems to work...
//public next(): Call2<ResourceMetadata>;
public next<NextResource>(): Call2<NextResource> {
return new Call2(this.resource);
}
}
interface FooRes extends Resource {
bar: string;
}
const resource1: Resource = {};
const call2 = new Call2({}); // <-- good, compile error
call2.resource._links; // <-- good, type ResourceMetadata found
const next1 = call2.next();
const next2 = call2.next<FooRes>();
next1.resource._links.self; // <-- bad, type ResourceMetadata not recognized
next2.resource._links.self; // <-- good
next2.resource.bar; // <-- good
Contributor
Author
There was a problem hiding this comment.
In typescript playground, it's supposed to work in TypeScript 3.3
| * @return Embedded resource or an `undefined` value | ||
| * @stable | ||
| */ | ||
| export function embedded<T>(rel: string, res: any, opts?: EmbeddedOpts<T>): Resource<T> { |
| */ | ||
| export function embeddeds<T>(rel: string, res: any, opts?: EmbeddedOpts<T>): Resource<T>[] { | ||
| if (hasEmbedded(res)) { | ||
| const em = res._embedded[rel]; |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.