The use of any makes exploration and understanding of the API difficult and prevents the editor from type-checking things.
In the case of getContentByPath and getPreviewContent their returned values are even passed to the OptimizelyComponent via the content prop which actually does have a type, OptimizelyContent (with ExperienceCompositionNode). Those types doesn't seem to match what's actually returned though (looks quite minimal in comparison), but it does contain things like __typename, which is helpful to know about. The type is also bit confusing though, like why are there both _composition and composition, why are there two?
Would be great if all methods on the GraphClient would be properly typed. If there are objects where the properties simply cannot be known beforehand, it would at least be helpful if the properties that are known are there, which I believe can be done like this:
type PartiallyKnownItem = {
id: string;
author: {
name: string;
};
[key: string]: unknown;
}
Additionally, it would be awesome if properties on these types were documented, or at least had links to official documentation where they were. As a new user, the Optimizely documentation site is quite vast and confusing, so would be great if I could simply hover over some prop in the type, like __typename, and get a short description in my editor, maybe with a link to where I can read up-to-date info about it on your website.
The use of
anymakes exploration and understanding of the API difficult and prevents the editor from type-checking things.In the case of
getContentByPathandgetPreviewContenttheir returned values are even passed to theOptimizelyComponentvia thecontentprop which actually does have a type,OptimizelyContent(withExperienceCompositionNode). Those types doesn't seem to match what's actually returned though (looks quite minimal in comparison), but it does contain things like__typename, which is helpful to know about. The type is also bit confusing though, like why are there both_compositionandcomposition, why are there two?Would be great if all methods on the
GraphClientwould be properly typed. If there are objects where the properties simply cannot be known beforehand, it would at least be helpful if the properties that are known are there, which I believe can be done like this:Additionally, it would be awesome if properties on these types were documented, or at least had links to official documentation where they were. As a new user, the Optimizely documentation site is quite vast and confusing, so would be great if I could simply hover over some prop in the type, like
__typename, and get a short description in my editor, maybe with a link to where I can read up-to-date info about it on your website.