Skip to content
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

Add support and tests for @return Promise<T> #12

Closed
wants to merge 1 commit into from
Closed

Add support and tests for @return Promise<T> #12

wants to merge 1 commit into from

Conversation

lovell
Copy link

@lovell lovell commented Nov 19, 2016

Hello, this small PR allows a function to return a Promise that will resolve to a given Type, e.g. @return {Promise<Object>}.

Prior to this PR, use of @returns {Promise<T>} mapped to the invalid Promise.<T>

Technically this will also add support for AnyContainer<T>, but the test case is specific to the use of a Promise as that's the problem I ran into - see lovell/sharp#472 (comment)

Promise<T> previously mapped to the incorrect Promise.<T>
@cryptiklemur
Copy link

Would love to see this

@englercj
Copy link
Owner

I think the problem is even larger than this, the question really is how to support built-in, non-primitive, types. That list of types is different depending on the env you build for.

In v2, it will try to lookup a ""Promise." type in the jsdoc information. When it can't find that it will log a warning and fall back to any. Obviously this is not desired, but I'm not sure what the best way is to differentiate between an unresolved object we should warn about and a built-in we should output as-is.

@stereobooster
Copy link

Alternative way is to check if it is present in TypeScript definitions, like "@types/node": "^8.0.46",.

Because tsc (starting from 2.3) can be used to validate types based on jsdoc it will require those definitions too.

@englercj
Copy link
Owner

Currently a basic version of built-in types is working in v2. Still need to add support for generic promises.

@englercj englercj added the bug label May 28, 2018
@lovell
Copy link
Author

lovell commented Sep 5, 2018

Closing as there seems to be progress being made on this (plus this PR is very much out of date).

@lovell lovell closed this Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants