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

TypeScript Documentation #669

Merged
merged 3 commits into from Jan 17, 2018
Merged

TypeScript Documentation #669

merged 3 commits into from Jan 17, 2018

Conversation

delvedor
Copy link
Member

@delvedor delvedor commented Jan 16, 2018

Me and @mcollina think that the types should stay inside the repo and shipped with the project.
We all discussed a lot in #649 about this, and this is our proposal.

Again, this is the best that thing we can offer, if someone does not agree with this, then he/she/them can start to contribute to the project and take care of this.

I've also moved the @types dependencies as dev dependencies, because it is not a good idea ship them directly as dependency. Then I added the @types dependencies inside the greenkeeper ignore, because every time there is a new release of the types for some unknown reason our CI will complain.

cc @fastify/fastify

Checklist

  • run npm run test and npm run benchmark
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows Code of conduct

@delvedor delvedor added discussion Issues or PRs with this label will never stale documentation Improvements or additions to documentation labels Jan 16, 2018
@@ -2,10 +2,17 @@

<a id="typescript"></a>
## TypeScript
Fastify is shipped with the a typings file so it should "just work" when used in a TypeScript application.
Fastify is shipped with the a typings file so it should "just work" when used in a TypeScript application.<br/>
*You should also install `@types/node` and `@types/pino`.*
Copy link
Member

Choose a reason for hiding this comment

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

can you make it explicit

npm i @types/node @types/pino

Copy link
Contributor

Choose a reason for hiding this comment

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

@types/node isn't always necessary. Typescript projects only need it for accessing node built-in classes. Most projects do need the built-in classes, so Typescript programmers are used to installing @types/node first thing as a matter of habit.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not yet clear to me whether either @types/node or @types/pino is actually needed in devDependencies for Fastify. I'll look into that this weekend.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since Fastify ships with a particular version of pino, it would make sense for @types/pino to stay in dependencies so that the pino version and its typings will stay in sync in this repo.

Copy link
Member Author

Choose a reason for hiding this comment

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

We try to ship always the latest.
I don't want to force not-typescript users to download useless stuff :)

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense @nwoltman. Spares TS devs from figuring out the right version of typings to use.

Copy link
Contributor

@nwoltman nwoltman Jan 16, 2018

Choose a reason for hiding this comment

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

@delvedor I don't want to force not-TypeScript users to download useless stuff either, but we're already doing that by including fastify.d.ts, which has a direct dependency on @types/pino.

TypeScript users should include @types/node themselves because they choose which version of Node to using, but since fastify depends on pino, it is fastify that chooses which version of pino to use.

We won't have to worry about this though if pino includes its own typings, which might happen soon at some point (see this discussion in the pino repo).

Copy link
Member

Choose a reason for hiding this comment

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

I'd be careful with that word "soon". Unless someone steps up with at least a PR, there will not be type in the pino module any time soon.

## Types support
We do care about the TypeScript community, but the framework is written in plain JavaScript and currently no one of the core team is a TypeScript user while only one of the collaborators is.
We do our best to have the typing updated with the latest version of the API, but *it can happen* that the typings are not in sync.<br/>
Luckly this is Open Source and you can contribute to fix them, we will be very happy to accept the fix and release it as soon as possible as patch release. Checkout the [contributing](#contributing) rules!
Copy link
Member

Choose a reason for hiding this comment

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

"as a patch release"

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

@allevo allevo left a comment

Choose a reason for hiding this comment

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

Absolutely LGTM!

Fastify is shipped with the a typings file so it should "just work" when used in a TypeScript application.
Fastify is shipped with the a typings file so it should "just work" when used in a TypeScript application.<br/>
*You should also install `@types/node` and `@types/pino`.*<br/>
`npm i @types/node @types/pino --save`
Copy link
Member

Choose a reason for hiding this comment

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

I assume this is to reduce bloat, but it might be confusing for folks using TypeScript since the versions aren't specified here whereas if included in package.json it would "just work" as claimed.

Copy link
Member

Choose a reason for hiding this comment

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

How about we rephrase it as:

Fastify is shipped with the a typings file, but it still require dependent types:

npm i @types/node @types/pino@4 --save

We might still ship @types/pino as a dependency, I'm not 100% sold on that. I would actually prefer if pino shipped with its own typings file.

## Types support
We do care about the TypeScript community, but the framework is written in plain JavaScript and currently no one of the core team is a TypeScript user while only one of the collaborators is.
We do our best to have the typing updated with the latest version of the API, but *it can happen* that the typings are not in sync.<br/>
Luckly this is Open Source and you can contribute to fix them, we will be very happy to accept the fix and release it as soon as possible as a patch release. Checkout the [contributing](#contributing) rules!
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -64,6 +64,8 @@
"node": ">=4.5"
},
"devDependencies": {
"@types/node": "^8.5.8",
Copy link
Member

Choose a reason for hiding this comment

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

Ideally we could keep these to prevent issues, but if there's a solid reason for moving then 👍

Copy link
Member

Choose a reason for hiding this comment

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

I think the issue is that Fastify works with Node 4, 6, 8 and 9. Fixing @types/node to a specific version is very confusing for a library.

Copy link
Contributor

@nwoltman nwoltman left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
discussion Issues or PRs with this label will never stale documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants