-
Notifications
You must be signed in to change notification settings - Fork 62
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
Modules return wrong type with no options (even though validateResult: true is default), unclear docs #21
Comments
@gadicc I'm more than happy to create a PR for this! Just wanted to check if this was something intentional first. |
Hi thanks, sorry, I only just opened my email and you've already done the PR. It is intentional 😅, it's the function overloading for different arguments. If you specify You'll see the difference as soon as you change the option, e.g. if you have
If you mouseover You can leave this issue open and I'll make this clearer in the docs. I'm out of time today though but will check back in tomorrow. |
PS same for the other way too: let result : any;
try {
// result is a SearchResult
result = await yahooFinance.search('AAPL');
} catch (error) {
// result is any
result = error.result
} because we're not sure of it's type anymore. |
@gadicc, ahh I see now. So essentially for all different modules you are exporting three variants of the function:
However, since |
You're absolutely right. |
There's actually only 1 function, your (3) above. The first two are the overloads (alternative function signatures). So (3) needs to accept the signatures for both (1) and (2) and contains the actual code. Typescript compiler will go through all signatures in order to pick the first one that matches (that's how this bug came up, because the order was wrong, they should move in increasing specificy). Not sure how well I explained that but there's more info at https://www.typescriptlang.org/docs/handbook/functions.html#overloads. |
Oops I wanted this open until I improved the docs. |
Morning @gadicc, you explained it very well! I read the official documentation just now as well. Thanks! |
You're too kind, thanks 😁 I have meetings on and off all day today but should be around here and there. |
# [1.7.0](v1.6.0...v1.7.0) (2021-02-10) ### Bug Fixes * **index:** uhhhh s/_options/_opts/ like it's called everywhere else ([4492993](4492993)) * **moduleExec:** pass correct object to validation ([#27](#27)) ([8b0f9c7](8b0f9c7)) * **modules:** change overloading order specificy (fixes [#21](#21)) ([1806e61](1806e61)) * **quote:** extend marketState property ([0c36a60](0c36a60)) * **quote:** interface fixes, 10am UTC tests ([#35](#35)) ([1c256c7](1c256c7)) ### Features * new module recommendationsBySymbol ([#28](#28)) ([b467acb](b467acb))
🎉 This issue has been resolved in version 1.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Issue
There are multiple default exports defined for the various modules, see below:
search
quoteSummary
quote
historical
autoc
I'm not sure if this is something intentional? Most of it was added in dc199b5
I noticed this because I saw that the return type for
search
was changed toPromise<any>
fromPromise<SearchResult>
, which caused my app to fail since I didn't get theSearchResult
type.Proposed solution
The text was updated successfully, but these errors were encountered: