histoire-dev / histoire-dev/histoire

Support undefined type on HST components

Open
#348 2 comments 1 reaction 0 assignees View on GitHub
enhancement: to triage
Dominant language
TypeScript
Stars
3.6k
Forks
212
PR merge metrics
No merged PRs in 30d

Description

### Clear and concise description of the problem

As a developer using Histoire I want HST components to support undefined type to that I can use the ComponentProps type.

Example:
```svelte
// SomeComponent.story.svelte

import type { Hst } from '@histoire/plugin-svelte';
import SomeComponent from './SomeComponent.svelte';
import type { ComponentProps } from 'svelte';

export let Hst: Hst;

let title: ComponentProps<SomeComponent>['title'] = 'Hello world';





```

```svelte
// SomeComponent.svelte

export let title: string | undefined;

{title}
```

### Suggested solution

Update Hst interface to support undefined value.

Example to update Text component
```typescript
Text: typeof SvelteComponentTyped<{
value: string;
title: string;
}>;
```
To
```typescript
Text: typeof SvelteComponentTyped<{
value?: string;
title: string;
}>;
```

### Alternative

_No response_

### Additional context

![image](https://user-images.githubusercontent.com/5345310/199465626-37c14c5d-6301-4ebf-b75d-9ac66c1c8109.png)

### Validations

- [X] Follow our [Code of Conduct](https://github.com/histoire-dev/histoire/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/histoire-dev/histoire/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://histoire.dev/guide/).
- [X] Check that there isn't [already an issue](https://github.com/histoire-dev/histoire/issues) that requests the same feature to avoid creating a duplicate.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.