Typescript definition improvement: Added types for payload property #997
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.
Description of the change
Improve typescript type definition.
Added types for Payload instead of using
object
Added comments with links to documentation
Added comments to aid in understanding code_version
Added optional Promise return type for transform
Motivation:
I spent hours trying to troubleshoot and figure out why items were not being matched up with source maps and the typescript definitions left me confused and unsure about how to configure the payload property because the documentation, at times, is not explicit about where a property lives.
For example, this page https://docs.rollbar.com/docs/source-control#serverroot makes it seem like there is a root level configuration option called
server
(which as far as I can tell that is not the case)And this example seems to show the
server
property in the root (I guess?) https://docs.rollbar.com/docs/source-maps#can-i-still-set-up-source-linking-when-using-source-mapsEither way, the payload property is well defined(ish) in the docs, so there is no reason it should be
object
in the type definition.I did add
[property: string]: any;
to ever level in thepayload
property and all nested children so that typescript users can supply anything they want, but will get type completion and jsdoc comments for known properties. I wasn't sure how else the payload is used outside what the docs mention.Type of change
Related issues
Checklists
Development
(These are all N/A since as far as I can tell, there are no tests for the Typescript definition file 😳 )
Code review