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

Why are typings not included in the package? #330

Closed
mvestergaard opened this issue Aug 4, 2016 · 11 comments
Closed

Why are typings not included in the package? #330

mvestergaard opened this issue Aug 4, 2016 · 11 comments
Assignees
Milestone

Comments

@mvestergaard
Copy link

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.

@mvestergaard
Copy link
Author

mvestergaard commented Aug 4, 2016

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.

@remojansen
Copy link
Member

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.

@mvestergaard
Copy link
Author

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.

@mvestergaard
Copy link
Author

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

@remojansen
Copy link
Member

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

@MeirionHughes
Copy link

MeirionHughes commented Aug 19, 2016

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.

@remojansen remojansen self-assigned this Aug 28, 2016
@remojansen remojansen added this to the 2.0.0 milestone Aug 28, 2016
@remojansen remojansen mentioned this issue Aug 28, 2016
18 tasks
@remojansen
Copy link
Member

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 😄

@remojansen
Copy link
Member

remojansen commented Aug 31, 2016

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!

@sanex3339
Copy link
Contributor

sanex3339 commented Aug 31, 2016

Looks like typings duplication. Did you completely remove old typings folder?
DefinitelyTyped/DefinitelyTyped#10729

@remojansen
Copy link
Member

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

remojansen added a commit that referenced this issue Sep 9, 2016
* Implemented #357

* [WIP] #330

* [WIP] #330

* Auto generate dts files

* Updated docs

* [WIP] trying to fix 'Cannot find global type Array'

* Removed tsify
@remojansen
Copy link
Member

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.

remojansen added a commit that referenced this issue Sep 9, 2016
* Implemented #357

* [WIP] #330

* [WIP] #330

* Auto generate dts files

* Updated docs

* [WIP] trying to fix 'Cannot find global type Array'

* Removed tsify

* Migrated from typings to @types

* Removed typings

* preparing for rc.14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants