-
Notifications
You must be signed in to change notification settings - Fork 176
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
Typings for horizon #684
base: master
Are you sure you want to change the base?
Typings for horizon #684
Conversation
**Typings URL:** https://github.com/beenotung/typed-horizon **Questions (for new typings):** * [x] Does the README explain the purpose of the typings and have a link to the JavaScript project? * [ ] Do the typings follow the source structure (e.g. `index.js` <-> `index.d.ts`)? no, the typing is in a single file * [x] Are they external or global modules according the source (e.g. see README sources)? they are global modules
The label should be typings request how to set the label? |
Definition files shouldn't contain values (https://github.com/beenotung/typed-horizon/blob/master/src/main.d.ts#L77-L80). Aside from that, is this for the browser API? Is everything global under |
@blakeembrey: yes, it is for browser, and the npm test script suggests it to be global |
changed to global typing; refer to raw file directly: eliminate the need to maintain a 'release branch' (reduce duplicated storage);
The test script say it is global because you choose it to be global when you run the generator. (You probably selected "Script Tag" when it asked "How can the package be used?") I checked the source and I think it is likely umd: // connect to the Horizon server, after Horizon has been loaded via
// <script> tag or require
const hz = new Horizon(); |
I need to find time to re-do part of the generator, or may be re-write it to be not depends on yeoman. It really tie my hand in properly refactoring the code. 😢 |
in this case, it should be in source (root folder) of npm? |
Thanks. You can also use classes into of this style: https://github.com/beenotung/typed-horizon/blob/master/global/main.d.ts#L2-L28. |
It depends on whom you want to support. If you want to support script tag usage, then this is fine. If you also want to support npm ( |
This general question interests me aswell, where should typings for modules go that support both global and commonjs usage? |
the current typing is for browser I am not sure if the nodejs part is the same, might check out that part later on I think horizon is not isomorphic, it seperate code under |
When talking about |
@felixfbecker to both |
@unional I guess I know your meaning but the client side horizon javascript is generated from live server on every request (i guess it embed some auth stuff) and i tried to eval the "client side code" in nodejs and it doesn't really work (cannot setup connect to horizon) becuase it used |
Nope that won't work. Your code will still need to be end up running on the browser, by either loading by script tag, requirejs, systemjs/jspm, etc. |
In either way, if this is ready, we can merge this and you can create another PR if you want to support npm module usage. |
@blakeembrey when using class, how to indicate the 'default function' ? I know using apply or call can do the trick, but it's not convenience for the user 😕
|
Oh, I missed that line doing that trick. It's a really weird pattern to do that, so your current code looks right. Also, what about |
the param in constructor is optional already 😄
you reminded me the typing is not completed, i'm just working on it progressively as far as my project cover |
@beenotung I was trying to point to the method you wanted (https://horizon.io/api/horizon/#connect - https://github.com/beenotung/typed-horizon/blob/master/global/main.d.ts#L7) - shouldn't it take a |
in order to import npm:rxjs (instead of typings:rx-lite previously)
@blakeembrey are you talking about the call method?
it works, but the syntax when invoking the method is trivial 😢
remark: |
@blakeembrey I just got you meaning, fixed :) |
when i use it in another project
how should I set the typings.json so that it will lookup under node_modules/ ? |
|
Typings URL: https://github.com/beenotung/typed-horizon
Questions (for new typings):
to the JavaScript project?
index.js
<->index.d.ts
)?README sources)?