Create templates based on the Data and Api type of a widget #889
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.
Type: feature
The following has been addressed in the PR:
prettier
as per the readme code style guidelinesDescription:
Widgets can prescribe the the shape of data required for a resource and the API itself. Currently it's really cumbersome to create a template based on the requirements of a resource widget. It requires the user to know the interface of both the data and the API and recreate the typings or import these interfaces/types from somewhere provided by the author. The widget is actually already "stamped" with these types so it would reduce friction significantly to enable users to pass a resource widget to the template factory and the factory infer the data type and resource API.
This is one approach that infers these types based on the generics passed to the
ResourceProperties
API, meaning that all forms of template are supported by passing the a resource widget.Note: To correctly infer all the types for the APIs and the api properties requires an bump the minimum supported version of TypeScript from
3.4.5
to3.5.3
.