Skip to content
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

feature: typescript declaration file support? #99

Closed
XGHeaven opened this issue Jan 18, 2018 · 13 comments
Closed

feature: typescript declaration file support? #99

XGHeaven opened this issue Jan 18, 2018 · 13 comments
Labels
Help Wanted Want to aid development? Look for these tags

Comments

@XGHeaven
Copy link

I use typescript with jayson, but there's no typescript declaration file.

Can you support it?

@tedeh
Copy link
Owner

tedeh commented Jan 18, 2018

Yes, let me have a look it should be possible since most of the method signatures are already quite well documented.

@XGHeaven
Copy link
Author

Because I use typescript. If module without declaration file, tsc would show a error. 😂
And sometime I don't know what's type of variable. It's troublesome to look up document.

@dcunited001
Copy link

i'm also hoping to use the jayson library with typescript. in particular, inside an Angular 4 library. i've tried running the typescript branch, but it seems there's a few errors in the index.d.ts file. i'm just getting back into webdev, so i'm almost completely unfamiliar with typescript.

@tedeh tedeh added the Help Wanted Want to aid development? Look for these tags label Apr 26, 2018
@tedeh
Copy link
Owner

tedeh commented Apr 26, 2018

@dcunited001 Yes you are right, I made a stab at a ts file a few weeks ago but am now swamped with work. Anyone that wants to help is welcome to fork and fix the definitions themselves. I estimate they should be 75 % done by now.

@dcunited001
Copy link

@tedeh for now, we're moving ahead only using the jayson client on the backend, but i would prefer to use it on the frontend. i'm just getting started with typescript myself, but if i get a chance, i'll try to take a shot at it.

@navono
Copy link

navono commented Aug 6, 2018

Is there any progress?

@tedeh
Copy link
Owner

tedeh commented Sep 8, 2018

I feel mostly finished with the Typescript implementation, anyone can add it to their project by checking out the typescript branch or running npm install 'github:tedeh/jayson#typescript'.

Would be good if anyone could write any feedback here ... The type definitions are probably not going to be merged into master unless I get some feedback from someone since I'm not a Typescript user myself yet.

Here are the type definitions: https://github.com/tedeh/jayson/blob/typescript/index.d.ts

@NicolasICible
Copy link

NicolasICible commented Sep 13, 2018

If the "noImplicitAny" config is set to "true" you get the following errors:

  • 'execute', which lacks return-type annotation, implicitly has an 'any' return type.
  • 'call', which lacks return-type annotation, implicitly has an 'any' return type.
  • 'request', which lacks return-type annotation, implicitly has an 'any' return type.
  • 'request', which lacks return-type annotation, implicitly has an 'any' return type.
  • 'request', which lacks return-type annotation, implicitly has an 'any' return type.

Easy fix just add : any as a result for these 5 functions. ( or a real type if applicable )

Everything else seems to be good. I'll add feedback here as I encounter something.

@tedeh
Copy link
Owner

tedeh commented Sep 16, 2018

Thanks for the feedback, the problems with noImplicitAny should have been fixed and pushed to the typescript branch now.

Any more help appreciated...

@luozhihua
Copy link

luozhihua commented Sep 20, 2018

In examples: server.js called the method: jayson.server(...), but in definitions file index.d.ts does not defined the method: jayson.server(), only has defined a class jayson.Server {};

image

[TS] property "server" in type "typeof import ("node_modules/jayson/index") "does not exist. Do you mean "Server"?

@tedeh
Copy link
Owner

tedeh commented Sep 20, 2018

Thanks @luozhihua unfortunately I couldn't manage to alias Server as server in the type definitions, so you probably need to use the uppercase version if you want the types to validate, unless you know how to alias definitions in typescript.

@tedeh
Copy link
Owner

tedeh commented Oct 11, 2018

The type definitions have been published in v2.1.0 for the general public to use. I expect there to be issues, but having them reported from now on as issues seems like a better way to get feedback.

@tedeh tedeh closed this as completed Oct 11, 2018
@jpike88
Copy link

jpike88 commented Oct 15, 2018

@tedeh Just using uppercase Server won't do the trick, it's a class, not a function.
screen shot 2018-10-15 at 9 55 54 am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted Want to aid development? Look for these tags
Projects
None yet
Development

No branches or pull requests

7 participants