Skip to content

Commit

Permalink
feat: support @required tag to denote required component props (#89)
Browse files Browse the repository at this point in the history
* feat: support `@required` tag to denote required prop (#22)

* Run "yarn test:snapshot"

* test(snapshots): add required props test case

* chore: do not include `@required` tag in TS definitions

* Run "yarn test:integration"

* test(integration): add `@required` prop to Dropdown

* Run "yarn test:integration"

* docs: add `@required`
  • Loading branch information
metonym authored May 19, 2022
1 parent f6ed263 commit e82aec9
Show file tree
Hide file tree
Showing 37 changed files with 2,088 additions and 1,108 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default class Button extends SvelteComponentTyped<
- [API Reference](#api-reference)
- [@type](#type)
- [@typedef](#typedef)
- [@required](#required)
- [@slot](#slot)
- [@event](#event)
- [@restProps](#restprops)
Expand Down Expand Up @@ -350,6 +351,36 @@ export let author = {};
export let authors = [];
```

### `@required`

By default, all props are typed as optional.

Use the `@required` tag to denote a component prop as required.

Example:

```js
/**
* This prop is required
* @required
*/
export let isRequired = true;
```

TypeScript output:

```ts
export interface ComponentProps {
/**
* This prop is required
* @default true
*/
isRequired: boolean;
}
```

Because `@required` is non-standard JSDoc tag, it is omitted from the prop comment in the TypeScript definitions.

### `@slot`

Use the `@slot` tag for typing component slots. Note that `@slot` is a non-standard JSDoc tag.
Expand Down
Loading

0 comments on commit e82aec9

Please sign in to comment.