New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR: Generate Typescript Typings from Manifest #74
Comments
This seems like a nice feature, but probably not one we'd bake in at least initially. While I'm a big fan of Typescript + React, the sample app is using ES6 for the simple reason that more people are using that compared to TS. Upon general release, the JSS JavaScript will be open source (Apache 2.0), including the manifesting pieces. You're more than welcome to build such a helper, and release your own JSS + React + TS sample app if you want to. :) |
Oh wow I didn't know about that! Regarding the typings: If you don't want to provide that feature for now could you maybe add |
By |
Yes exactly - addComponent requires addComponent: (...components: ComponentDefinition[]) => void; ComponentDefinition includes export interface ComponentDefinition {
name?: string;
displayName?: string;
/**
* The data fields that provide content data to the component
*/
fields?: FieldDefinition[];
/**
* The names of JSS placeholders that this component exposes
* (keys of any placeholder components added to this component's JS view)
*/
placeholders?: PlaceholderDefinition[] | string[];
/**
* Defines non-content parameters.
* Parameters are more developer-focused options than fields, such as configurable CSS classes.
*/
params?: string[] | RenderingParameterDefinition[];
// ....
} So all components are able to define Unfortunately the only public method of the So although I defined all my values with There are probably a lot of different solutions:
|
Correct, the interface used by disconnected mode is the generated manifest, not the object the manifest json is generated from. This has its advantages and disadvantages, to be sure. Have you considered finding the params by looking at the renderings in the manifest (json)? |
Hey @kamsar while this would probably possible it would cause very hard to understandable and maintainable code in every project that follows such an approach because the developer has to have a very deep understanding of the manifest structure and I am not sure if it will work if a property isn't used in any rendering. The So if you could maybe split that a little bit so that it would be possible to access the full parsed values ( This pattern could also allow to reuse one file watcher of the |
This has been automatically marked as stale because it has not had recent activity. It will be closed if there is no further activity within 30 days. You may add comments or the 'keep' label to prevent it from closing. Thank you for your contributions. |
The manifest knows the fields of a component however without typings this information are lost and we don't get intellisense and type checking for our components.
In the following video you can see the
src/components/Styleguide-FieldUsage-ItemLink
from the Sitecore/jss react boilerplate with and without typings:Describe the solution you'd like
I hacked a very very basic proof of concept into `scripts/disconnected-mode-proxy.js` to transform the manifest into a generated source file `src/temp/ComponentProps.ts`.
Click here to expand the code
The generated definition which is used for the video above looks like this
Click here to expand the code
Unfortunately the manifest does not include information about the
params
.It would be cool if you could provide a helper to generate not only the json for the
sidecore-import.json
but also the typings including theparams
.This would help new developers to get into JSS more easily because of intellisense and type checking.
The text was updated successfully, but these errors were encountered: