hello.js
hello.js copied to clipboard
Add TypeScript definition
Thanks a lot for this amazing library.
Have you any plan to provide a Typescript definition for hello.js? It simplified ids integration to large projects.
Thanks advanced
Hi @PavelPZ I'm not familiar with Typescript, could you elaborate?
Hi @MrSwitch, Yes, I can. I put it to the https://github.com/borisyankov/DefinitelyTyped repository.
"I put it to the ...."
Great, so do i need to do anything? Is there anything i need to include, like with Bower?
Hi, pull request to repository is prepared (see https://github.com/borisyankov/DefinitelyTyped/pull/2042).
If you want to use TS definition on you site, download it from https://github.com/PavelPZ/DefinitelyTyped, choose link
I tried to select one from many possible object oriented approach, I am open to change it.
Hey thanks @PavelPZ I've not come across this before. Do you use DefinitelyTyped with a particular IDE, plugin or code linter?
Hi @MrSwitch, hellojs is in master github now :-).
For JavaScript development I use MS Visual Studio. After including some of DefinitelyTyped definition to your project, I can use all goodies, which strictly typed language offer:
- hints for all object properties x methods from imported definitions during codding
- rename properties, functions etc. in your code
- find all reference
- "compile" errors (compiling here means to generate native JavaScript from Typescript)
- and more...
Great, well done
Visual Studio: I thought as much, TypeScript being a product of Redmond and all.
I've a couple of questions which i feel might need answering down the line...
- Would a conflict arise on your IDE if a NodeJS version, having a slightly different API, yet sharing the same namespace 'hello' exist?
- Also would you be up for maintaining this if/when the API changes? FYI i'm intending to add support for Promises 'then', 'catch' etc.. e.g. hello.api(args..).then(handler);
I'll close this issue, as it is currently resolved, but please carry on the conversation.
Hi @MrSwitch,
- all interface names start with "HelloJS" prefix. The only "hello" is in "declare var hello: HelloJSStatic;" which reflects your "var hello = function(name){..." statement
- yes, I can modify Typescript interface when new version arrives.
Can I provide one small hint? It will be great if features, which are not part of OAuth2 functionality (promises, ajax, ...), are separated to one utils unit (or class or object etc.). And if I use your hello.js with libraries like jquery.js, zepto.js, WinJS, I can remove this utils and replace it with already included library. In mobile world the size of JS files is important...
P.
Great thanks @PavelPZ
I too have found the code base a little too coupled, especially whilst working on a Node implementation.... So, you'd be pleased too hear an AMD branch is working well - checkout https://github.com/MrSwitch/hello.js/tree/feature-amd . This does not change the core functionality but does remove hello.utils
methods.
Branch feature-amd
will shortly replace the current master - after the migration of the demos/* etc.
Hi @PavelPZ
HelloJS supports promises (http://adodson.com/hello.js/demos/promises.html) and has removed support for hello.ap().complete(), hello.ap().success(), hello.ap().error()
that will probably affect your typescript definition.
Hey, Loving HelloJS. However it appears that the typescript d.ts hasn't been updated for some time and isn't aware of ng.IPromise
Hey guys, same as @pra2006, loving HelloJS, but I fail to find an example to use it in typescript :( I'd like to add it to an Angular2 app, is there any example out there? All searches on Hello and Angular2 return hello world examples...
Hello @PavelPZ , Can you please provide the updated typescript? Also, I'd like to use the library in anulgar4 application, do you have any usage example of hellojs typescript?
I went through the code and the documentation, and updated the type definitions as well as I could. Any feedback is welcome :)
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/18318
Ideally those type definitions should be moved to a /types folder and the package.json should be updated to contain a types entry. DefinitelyTyped is only here for repos that "don't want the types".
@vuorinem To authenticate an Angular SPA against MS Azure B2C, I need to specify the response_type
to be token id_token
. This is not allowed by the type HelloJSTokenResponseType
definition in version 1.16.0. See sample code here.
@hhubik good point, I probably mistook the "example values" from the documentation as the list of all possible values.
Do you think the list of OAuth Authorization Endpoint Response Types would work, or should the type or response_type rather be just a string? One problem with the list is that the type would probably need to specify all the possible orders of the parameters (e.g. "id_token token" and "token id_token").
@vuorinem My preference would be to replicate the entries from the "OAuth Authorization Endpoint Response Types" list. I consider "id_token token" and "token id_token" to be "functionally" identical. Therefore I would include only one of them, probably the first one where the types are in alphabetical order, which is what the IANA folks appear to have done.
Created a pull request: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24672