Inversifyjs: Why are typings not included in the package?

Created on 4 Aug 2016  路  11Comments  路  Source: inversify/InversifyJS

I don't quite get why you distribute types in a separate npm package instead of including them in the same package and using the "typings" setting in package.json.

See https://github.com/reactjs/redux/blob/master/package.json#L8 for an example.

enhancement

Most helpful comment

Ok guys so I have good news. The npm module includes now the typings and they are auto-generated. The bad news is that I have to migrate all the other modules and they are not ready yet. There is a new issue to follow the progress on that so I'm closing this issue.

Also is interesting to mention that it was possible thanks to an option I wasn't aware. It allows you to target ES5 but use some ES6 features without external libraries. Check "lib Option" in https://basarat.gitbooks.io/typescript/content/docs/types/lib.d.ts.html to find out more.

All 11 comments

It also appears that the typings in inversify-dts come from DefinitelyTyped, but since the project is written in TS, why not let TS generate the .d.ts files?

You might have a good reason, it just seems backwards to me.

See https://github.com/mobxjs/mobx for another example. Written in TS, definitions are generated and included in package.json.

Hi,

Thanks for your feedback. Our problem is that our type definitions have some third party dependencies this means that they contain triple-slash references and for that reason we can't use typings for npm.

From the TS docs:

Your definition files should

be.d.ts files
be written as external modules
not contain triple-slash references

About why not using the auto-generated dts files... when we started the project there was no support for the auto-generation of the dts of UMD modules I think it will be possible in TS 2.0.

We have plans to fix these two issues with TypeScript 2.1 becomes available all our Promise based APIs will be migrated using async/await and we will then be able to remove third party dts from bluebird. If you think that you can helps us to improve this we would be happy to accept a PR.

Are there other third party typings needed except for bluebird? Because I would think it would be pretty easy to create your own typings for a simple promise interface, bluebird is most likely overkill.

I would actually even think you can just use the typings from lib.es6.d.ts that ships with typescript, and it can automatically output them for you in the definitions, but don't hold me up on that.
If not, I would just copy them from lib.es6.d.ts

Yes, bluebird is the only one.I think lib.es6.d.ts is applied when targeting ES6 but we target ES5.

I was surprised there were no typings too :D. Thankfully they are available via: @types/inversify (need to use typescript 2.0)

Note, any @types modules that needs to be installed by your lib consumers needs to be in dependency while typings for say @types/jasmine can go in devDependencies.

Hi, I have submit a PR to DefinitelyTyped after it gets merged all the type definitions will be available via @types. This requires TypeScript 2.0 so the next step for us will be to tests all the modules using TypeScript 2.0. We will try to remove typings as well for third party dependencies and use @types instead. If everything goes well I will update the docs to document the new installation process. Once this is done I will finally release InversifyJS 2.0 :smile:

Hi guys I'm working on this and I have some problems.

I'm trying to remove typings and use @types instead for our dev dependencies. I also removed bluebird and replaced with core-js (this is what the guys from Angular 2.0 are doing).

I'm having the following problem:

$ gulp
[01:06:44] Using gulpfile ~/CODE/forks/InversifyJS/gulpfile.js
[01:06:44] Starting 'default'...
[01:06:44] Starting 'build'...
[01:06:44] Starting 'lint'...
[01:06:55] Finished 'lint' after 11 s
[01:06:55] Starting 'build-bundle-src'...

events.js:154
      throw er; // Unhandled 'error' event
      ^
TypeScript error: 
/CODE/forks/InversifyJS/node_modules/@types/chai/index.d.ts(412,11)
Error TS2451: Cannot redeclare block-scoped variable 'Object'.

You can see my changes here. I'm working on a fork.

Any help would be much appreciated.

Thanks!

Looks like typings duplication. Did you completely remove old typings folder?
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/10729

I'm just copying this link here so I can use it as a reference later... https://basarat.gitbooks.io/typescript/content/docs/types/lib.d.ts.html

Ok guys so I have good news. The npm module includes now the typings and they are auto-generated. The bad news is that I have to migrate all the other modules and they are not ready yet. There is a new issue to follow the progress on that so I'm closing this issue.

Also is interesting to mention that it was possible thanks to an option I wasn't aware. It allows you to target ES5 but use some ES6 features without external libraries. Check "lib Option" in https://basarat.gitbooks.io/typescript/content/docs/types/lib.d.ts.html to find out more.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

remojansen picture remojansen  路  4Comments

remojansen picture remojansen  路  4Comments

RastriginSergey picture RastriginSergey  路  3Comments

AriaFallah picture AriaFallah  路  4Comments

Deviad picture Deviad  路  3Comments