Add TypeScript typings #39
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Spent some time trying to complete this tonight. Please review as accurately as possible. All of my types are from reading the code. I based some off of the JSON Schema object but also included anything written in the documentation too. There were a couple
anytypes I'd like to see if we can make more specific, as well as some general questions I have:portproperty on theInjectOptions.urltype ofstring | number?query? Could this be typed asstring?payloadbe? I've implemented it as a generic for now but I think we can scope this to an union type list:string | object | Buffer | NodeJS.ReadableStream(this is actually copied from the currentfastify.d.tstypesHTTPInjectOptionsso I believe it should be safe to implement here as well). Depending on what happens here I'll most likely be removing the generic.Response._lightMyRequest.payloadChunksis of typeArray<Buffer>?Not ready to be merged yet as I'm still playing with
tsdto test the new types. It is a young module with a tiny API so it might not be quite ready yet, but I'd like to revisit it with a clear head tomorrow.Finally, I need to experiment with the declaration file exports, namespace, and some of the internal TSC stuff I used (such as
interface) to make sure it is correct.