Skip to content

Avoid any in types (e.g. getContentByPath and getPreviewContent) #387

Description

@Svish

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions