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

added definitions for TypeScript #9

Merged
merged 4 commits into from
Mar 24, 2020
Merged

Conversation

winfinit
Copy link

added typings, so module is going to play nice with typescript, and won't require additional @types module.

@brunokrebs
Copy link
Collaborator

Hey @winfinit, thanks for your contribution. I've been wondering about that. As per what you are saying, if we describe a library interface in a index.d.ts file, it will make it compatible with TypeScript. Is that correct?

If so, why do they created DefinitelyTyped (@types)? Furthermore, could you please provide me some reference that confirms this?

Thank you again.

@Foxandxss
Copy link
Owner

We definitely want this. I am not so sure about the version bump you did (as a piece of advice, never do that, you don't know if the person wants to release after your PR or not. And even so, you don't know to which version).

@brunokrebs So back in the day, the only way of doing typings was via DefinitelyTypes which after a few steps ended with the official solution of @types as you mention.

That being said, a GOOD library can always provide the typings directly with the package. So only by installing the package via npm, you have typescript support out of the box without having to look for third party typings elsewhere.

So yes, please, but remove the package bump.

@@ -0,0 +1,21 @@
import Koa = require("koa");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this line? I am not sure, but I could be mistaken.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, otherwise Koa.Middleware type is not going to get resolved

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right you are.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You haven't added @types/koa to dependencies. This won't work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at the Dependencies section of this page.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brunokrebs added @types/koa to dev dependency list.

Copy link
Collaborator

@brunokrebs brunokrebs Apr 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it should be added as in the dependencies property. Otherwise, it won't work.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brunokrebs why would you want to add it to dependencies, it is a TypeScript dependency, which is used only during development phase

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@winfinit, exactly what I thought when I wrote this type definition. I first added it as a devDependency and then why I wrote a small Koa application with TypeScript to test the definition, but it kept complaining about not being able to find @types/express-jwt.

After that I saw that the publishing page on the TypeScript documentation states that the developer has to:

Make sure all the declaration packages you depend on are marked appropriately in the dependencies section in your package.json.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brunokrebs ah, just re-read that post, you are right, they are even saying this explicitly:

Our package exposes declarations from each of those, so any user of our browserify-typescript-extension package needs to have these dependencies as well. For that reason, we used "dependencies" and not "devDependencies", because otherwise our consumers would have needed to manually install those packages. If we had just written a command line application and not expected our package to be used as a library, we might have used devDependencies.

@winfinit
Copy link
Author

version bump was removed. I actually prefer in my packages when people bump a version, as long as they are following semver, that way I just need to merge and publish package, but hey, your package, your preference :)

@winfinit
Copy link
Author

@Foxandxss and @brunokrebs is there anything outstanding for me?

@Foxandxss
Copy link
Owner

No, I am just busy with work :(

@winfinit
Copy link
Author

@Foxandxss gotcha, there is no rush, just wanted to make sure that you are not waiting on me. Have fun!

@mariotacke
Copy link

Can we merge this please?

@dedpnd
Copy link

dedpnd commented Sep 24, 2019

Hi, may be you can merge?

@karladler
Copy link

@Foxandxss can you merge this please? :)

@Foxandxss Foxandxss merged commit 97364bd into Foxandxss:koa-v2 Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants