Skip to content
This repository has been archived by the owner on Jul 6, 2018. It is now read-only.

[ember-data]: Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method #74

Closed
theseyi opened this issue Jan 18, 2018 · 5 comments

Comments

@theseyi
Copy link

theseyi commented Jan 18, 2018

When using async/await on an ember Route model, awaiting the result of store.findRecord throws the following typescript exception. (in the comment below)

async model(): Promise<any> {
  const store = get(this, 'store'); 
  await store.findRecord('someStoreRecord', 1); // Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method
  }

Using a .then works as expected. This issue arises with as mentioned, using async/await

Could this be an issue with the return type definition for store.findRecord which is PromiseObject<T> & T?

@dwickern
Copy link
Collaborator

Is it still broken on ts@next?

@cptran777
Copy link

Recreated this same issue using ts@2.7.0-dev.20180118

@theseyi
Copy link
Author

theseyi commented Jan 18, 2018

@dwickern yea, still broken. Asserting that the returned value is a <Promise<T> & T>... works masks the issue

@dwickern
Copy link
Collaborator

I had a quick look. It's caused by the self-recursive nature of PromiseObject and PromiseArray (they are promises which resolve to themselves). To fix this we might have to break some pathological scenarios around promise proxies, but I won't lose any sleep over it.

I'll open a PR in the next couple of days if nobody else gets to it.

@dwickern
Copy link
Collaborator

Fixed by DefinitelyTyped/DefinitelyTyped#23238

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants