Hapi: Add and Publish TypeScript definition with hapi package

Created on 6 Jan 2017  路  10Comments  路  Source: hapijs/hapi

I see there are two older issues related to maintaining typescript definitions; but these relate to getting them on definitely-typed. Recently typescript has moved forward and now supports npm packages declaring their own types. This is done via a "typings": "path/to/types.d.ts" in the package.json.

Please consider adding, maintaining and publishing typescript definitions to this (and other repos); By having it in the repo, its far easier to maintain and keep up-to-date. Potentially, this could simply be started by copying the definitely-typed definition file into here.

Finally, uptake in typescript is rapidly growing and reducing any conflicts between typing and run-time is probably worth the effort.

feature

Most helpful comment

@AJamesPhillips The @types modules are built from DefinitelyTyped.

I have been slowly updating the hapi types an a adding new ones for hapi subprojects like lab as we roll all our code to TS. Once the roll is complete and I am sure they are correct I will PR at DT and maintain. That should be the best solution for everybody I think.

All 10 comments

its far easier to maintain and keep up-to-date

As far as I know, no one in this organization is using typescript daily or at all. Those files will likely be either stale or wrong very quickly.

Before anything, I am a happy TypeScript user in some fields and I know how useful are typings files.
However I do not feel the hapi team has to create such file: it would be a lot of work and a commitment to maintain this as the framework evolves. hapi is a Node.js framework written in JavaScript and is aimed at being used with this language.

If someone commits to maintain it for the next few years, I might agree. But atm. I do not think it should happen.

Agreed. The typings that exist are already pretty outdated, so would need to be reviewed for correctness and updated in the first place on top of maintained for changes across multiple projects. This is a very significant undertaking. Unless someone who already knows and uses typescript and is deeply familiar with hapi volunteers, I don't see this happening any time soon.

Okaydoky; having looked at the typings I agree it would require a lot of effort to maintain it manually.

Thanks for the comments maintainers and thanks for the excellent HapiJS.

@MeirionHughes I don't know if you've seen this: https://www.npmjs.com/package/@types/hapi It should allow for using the .d.ts and for saving the hapi team from the noise that goes along with keeping it up to date.

@AJamesPhillips The @types modules are built from DefinitelyTyped.

I have been slowly updating the hapi types an a adding new ones for hapi subprojects like lab as we roll all our code to TS. Once the roll is complete and I am sure they are correct I will PR at DT and maintain. That should be the best solution for everybody I think.

@corbinu I was going to attempt to update the hapi js .d.ts to version 16.1 . I tried to find your work on your repo at [email protected]:corbinu/DefinitelyTyped.git but my git fu hasn't succeeded so far. Could you point me towards a commit/branch with some of your recent work on it. Thank you very much.

Another thought that struck me as I started planning this endeavour is that a lot of the value of hapi is in the plugin ecosystem which would need to be similarly typed...

@AJamesPhillips The types aren't finished yet. Honestly not sure if I am going to bother anymore as it is such a small part of my app that is not typed and the API is the easiest to smoke test. So just going to use it as an "any"

I've completed updating the types for hapi 16.1.1 and some of the plugins: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/15963

@AJamesPhillips Your index.d.ts file for @types/hapi does not have the latest changes (released as v16.0.1 recently). Also, I noticed you are missing types for @types/chai in your repo?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kevinsimper picture kevinsimper  路  4Comments

taoeffect picture taoeffect  路  3Comments

hueniverse picture hueniverse  路  4Comments

hovmand picture hovmand  路  3Comments

jeffbski picture jeffbski  路  5Comments