hello.js icon indicating copy to clipboard operation
hello.js copied to clipboard

Add TypeScript definition

Open PavelPZ opened this issue 10 years ago • 19 comments

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

PavelPZ avatar Apr 12 '14 08:04 PavelPZ

Hi @PavelPZ I'm not familiar with Typescript, could you elaborate?

MrSwitch avatar Apr 12 '14 11:04 MrSwitch

Hi @MrSwitch, Yes, I can. I put it to the https://github.com/borisyankov/DefinitelyTyped repository.

PavelPZ avatar Apr 14 '14 09:04 PavelPZ

"I put it to the ...."

Great, so do i need to do anything? Is there anything i need to include, like with Bower?

MrSwitch avatar Apr 15 '14 06:04 MrSwitch

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 from the list.

I tried to select one from many possible object oriented approach, I am open to change it.

PavelPZ avatar Apr 15 '14 11:04 PavelPZ

Hey thanks @PavelPZ I've not come across this before. Do you use DefinitelyTyped with a particular IDE, plugin or code linter?

MrSwitch avatar Apr 15 '14 13:04 MrSwitch

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...

PavelPZ avatar Apr 16 '14 07:04 PavelPZ

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...

  1. Would a conflict arise on your IDE if a NodeJS version, having a slightly different API, yet sharing the same namespace 'hello' exist?
  2. 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.

MrSwitch avatar Apr 16 '14 07:04 MrSwitch

Hi @MrSwitch,

  1. all interface names start with "HelloJS" prefix. The only "hello" is in "declare var hello: HelloJSStatic;" which reflects your "var hello = function(name){..." statement
  2. 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.

PavelPZ avatar Apr 22 '14 12:04 PavelPZ

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.

MrSwitch avatar Apr 22 '14 13:04 MrSwitch

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.

MrSwitch avatar Sep 27 '14 14:09 MrSwitch

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

ghost avatar Mar 20 '15 08:03 ghost

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...

Sn3b avatar Apr 20 '16 13:04 Sn3b

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?

amigup avatar Apr 28 '17 14:04 amigup

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

vuorinem avatar Jul 23 '17 01:07 vuorinem

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".

baywet avatar Feb 27 '18 21:02 baywet

@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 avatar Apr 01 '18 14:04 hhubik

@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 avatar Apr 01 '18 14:04 vuorinem

@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.

hhubik avatar Apr 01 '18 15:04 hhubik

Created a pull request: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24672

vuorinem avatar Apr 01 '18 20:04 vuorinem