Type declarations for missing properties #51
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.
This PR adds type definitions for the static values for
INITIALIZING
,CONNECTING
,OPEN
andCLOSED
.This is a backwards compatible change.
I also took the liberty of optimizing the build, since the d.ts file should be generated from the jsdoc.
Unfortunately it seems the
sse.d.ts
file was updated manually in 5471ff1, so it is out of sync with the source. This also means the sourcemap is inaccurate.I fixed this as best I can, but with one caveat: The constructor (
new (url: string, options?: SSEOptions): SSE;
) cannot be extracted from jsdoc usingtsc
.This is due to the fact that SSE is defined as a
type
, when it should beinstance
orclass
.Consequently, when running
tsc
the constructor will be removed from the d.ts and needs to be added back in manually.I don't think there is a workaround for this (or at least I didn't find any).
To get the output back in sync with the source, a more extensive rewrite of the types is likely due and should probably be tested using
tsd
or the like.When considering such a rewrite however, my recommendation would be to refactor the code to use typescript with ecma 6 classes.
This way you could ensure compatibility with EventSource (
extends EventSource
) and get proper always-in-sync type definitions for free without the effort of separate definitions.