feat: more strictly type [everything, really] #4
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.
using
@types/json-schemafor most type changes here, as well as adding@types/wsfortscreasons (if this is not wanted then@types/wscan be moved tooptionalDependencyon package.json)also now exports an
ActionDatainterface for downstream projects to use, over at NeuroPilot we just made our own version of it but it'd be good to share this upstream.all instances of the
anytype in the code has now been removed with this PR, should help typescript-supported compilers catch type errors betterresult of all of the above is that types are now much clearer and people who want to strictly type their projects can do so just a tiny bit better.
one thing though is that the
commandtype is now changed fromstringto specific strings, these are based on current specs + proposals, which means that these have to be updated in the code each time there's a change. currently this isn't that big of an issue since API spec changes aren't that common, but if they do get common this may need to be rethought about.(the other commands also aren't currently handled at all and are treated as if they are unknown commands)
There are now also some type coercions in the code, not sure if this is a good idea so if not let me know and I can try to convert them to typed constants before merge.