-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not Assignable Types That Should Be #3672
Comments
This is all I could come up with:
While this works, it feels highly inflexible. Anytime I wrap something with IResource and need to access properties on the generic, I would need to create another interface. |
Is it the case that something that is If so, it seems like intersection types (#3622) should be able to model this. |
Closing for housekeeping reasons; feel free to comment in the future (we do watch closed issues) |
running into this now... just trying to have a generic service returning a promise of an array strange that this works... public get(id: number): ng.IPromise<T> {
var promise = this.svc.get(id);
var dfd: ng.IDeferred<T> = this.$q.defer();
promise.then(function (tDto) {
dfd.resolve(tDto);
}, function (ex) {
dfd.reject(ex);
});
return dfd.promise;
} but this does not public query(): ng.IPromise<Array<T>> {
var promise = this.svc.query();
var dfd: ng.IDeferred<Array<T>> = this.$q.defer();
promise.then(function (tDto) {
dfd.resolve(tDto); // error!
}, function (ex) {
dfd.reject(ex);
});
return dfd.promise;
} |
@goleafs can you get this to be a self-contained repro? There are many promise libraries floating around out there so it's hard for us to check these things locally. |
I'm using angular-resource.d.ts
And this code has the line generating the error.
I feel like filter.options = companies should be valid. ICompany and IGridFilterOption have the same properties. IResource is simply a wrapper around ICompany that adds CRUD ops to it. IResourceArray extends Array by adding promise related properties.
What needs to be changed in the type definitions to make this assignment valid?
The text was updated successfully, but these errors were encountered: