-
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
Does not work with Angular 11 #153
Comments
Hey @whoiscarlo, thanks for reporting. I don't have any experience with Angular but this seems to be a TypeScript error, so not sure why we haven't noticed it before. Looking at the typescript docs for allowSyntheticDefaultImports, it sounds like you can either set this option to import * as yahooFinance from "yahoo-finance2" I'll note also that we're busy working on better module support in #144, which will probably land later this week or next week, which should result in you being able to import yahoo-finance2 like normal and without any special flags. (Also, importing as in the above might break when this lands, so changing the config option (temporarily) is probably a safer bet). Please leave this issue open and we'll update when the above code is merged and released. |
Oh and, on another note, this package (and the original) aren't well suited for running in the browser. We made sure in this release to make sure it can be loaded in the browser, but network requests to Yahoo's servers will be blocked by CORS, and you'll need a proxy server to get around that. There's a small note about it in the README (on this repo). However, if you're using this server-side with Angular you'll be fine (I don't really know exactly how the ng build process works). |
@gadicc dude you're the man!! Thanks for even taking the time to respond to this. I'll try out that solution and see how it goes. I be honest and admit I didn't fully read the README as I should have 😓 and just dived, in so I'll be better with that next time. And as a completed noob developer I had no idea what a CORS error was or how to get around it, so after 2 days of messing around I built myself a small Go-Fiber rest api and started querying data from Yahoo's API directly 😅 |
Great stuff, happy I could help. Sure, see how you go. And maybe it's not a bad idea for us to log a warning to the console when used in the browser, I've surely badly skimmed READMEs before in my time. |
# [1.11.0](v1.10.4...v1.11.0) (2021-06-01) ### Bug Fixes * **deps:** update dependency ajv to ^8.1.0 ([1769641](1769641)) * **quoteCombine:** resolve `undefined` for missing symbols ([#150](#150)) ([f8c25e3](f8c25e3)) * **testing:** specify jest.js path, not bin ([#170](#170)) ([6772c8e](6772c8e)) ### Features * **options:** accept `date` option ([#186](#186)) ([11b8a72](11b8a72)) * add (friendly) warning when used in the browser ([3c4c5a0](3c4c5a0)), closes [#153](#153) * add insights module ([#169](#169)) ([4603232](4603232)) * **concurrency:** ability to limit max simultaneous requests ([#76](#76)) ([3424d44](3424d44)) * **modules:** build (true) esm, (interop) cjs modules; tests/readme ([#144](#144)) ([2182f6c](2182f6c)) * **setGlobalConfig:** add setGlobalConfig function ([#133](#133)) ([43ebaa4](43ebaa4))
Hey @whoiscarlo, I don't think you're actually still using |
Bug Report
Describe the bug
Error: node_modules/yahoo-finance2/api/index-common.d.ts:1:8 - error TS1259: Module '"/Users/darknyte/Dropbox/Sandbox/angular/lucrative/node_modules/yahoo-finance2/api/lib/yahooFinanceFetch"' can only be default-imported using the 'allowSyntheticDefaultImports' flag
Minimal Reproduction
Create a brand new angular project
ng new yahoo-test
install yahoo-finance2:
npm i yahoo-finance2
In app.component.ts
add
import yahooFinance from 'yahoo-finance2';
Save file
Then run
ng serve
Repo Link
Environment
Node version : v15.4.0
Npm version: 7.11.2
Angular: 11.0.5
Typescript: 4.0.2
TS Lint: 6.1.0
TS-Node: 8.3.0
The text was updated successfully, but these errors were encountered: