histoire-dev / histoire-dev/histoire
Support undefined type on HST components
- 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

### 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
Assessment
This issue has not been assessed yet.