Skip to content
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

feat: add generic types to get story functions #854

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AdrianFahrbach
Copy link

Pull request type

Jira Link: No Jira Link available.

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Other (please describe):

How to test this PR

This PR introduces type changes to .get, .getAll, .getStory and .getStories. The new behaviour can be tested by using those functions with generic types like this:

import StoryblokClient from 'storyblok-js-client'

interface MyCustomType {
  foo: bar;
}

let client = new StoryblokClient({
  accessToken: '<YOUR_SPACE_ACCESS_TOKEN>',
})

const res = client.getStory<MyCustomType>('home')

If you hover over res in your IDE it should be of type ISbStory<MyCustomType>

What is the new behavior?

This PR adds optional generic types to these functions to allow for easier typing when using this client.
With ISbStory and ISbStories there already are generic interfaces for typing stories, those had to be manually assigned for now though. ISbResult got generic in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant