-
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
Typescript error when passing an already declared array into quote
fields
#808
Comments
maybe we could add a you can close this if it's a duplicate of #807, not 100% sure |
Hey, @Yhprum. I think we need the - const YAHOO_QUOTE_FIELDS = ["regularMarketPrice"] as const;
+ const YAHOO_QUOTE_FIELDS = ["regularMarketPrice" as const]; That fixes the error for me. However, I also like your idea of exporting import type { QuoteField } from "yahoo-finance2/dist/esm/src/modules/quote";
const YAHOO_QUOTE_FIELDS: QuoteField[] = ["regularMarketPrice"]; Thanks for raising this 🙏 |
# [2.13.0](v2.12.5...v2.13.0) (2024-09-29) ### Bug Fixes * **options:** re-export missing types ([#797](#797)) ([e96395f](e96395f)) * **setGlobalConfig:** cookieJar prop should be optional (fixes [#809](#809)) ([7e524fc](7e524fc)) ### Features * **quote:** export `QuoteField` type ([#808](#808)) ([a1f07d7](a1f07d7))
Out in 2.13.0. |
Thanks a bunch for this (and my other issues)! This works great with the exported type. The reason I didn't want to to the Appreciate the quick response! |
Hey, sure, and thanks for reporting back! These are all a few quirks that slipped through our new typescript / validation architecture so very grateful to have the reports and get to crunch them asap. So thanks again 🙏😁 |
Bug Report
Describe the bug
Typescript error when passing a prebuilt array into
quote
fieldsMinimal Reproduction
const YAHOO_QUOTE_FIELDS = ["regularMarketPrice"] as const;
yahooFinance.quoteCombine("AAPL", { fields: YAHOO_QUOTE_FIELDS })
Environment
Browser or Node: node
Node version (if applicable): 20.9.0
Npm version: 10.1.0
Browser verion (if applicable):
Library version (e.g.
1.10.1
): 2.12.5Additional Context
since the quote fields are the list of options and not a generic
string[]
, I can't pass an array of options in like I was previously (this is good though, I like the stricter typing of options. However the way I generaly deal with this is addingas const
after the array to make the type the literal strings instead of a generic string array, but I get this error now.The type <myType> is 'readonly' and cannot be assigned to the mutable type <yourType>
The text was updated successfully, but these errors were encountered: