Skip to content

Commit

Permalink
chore(playground): add generics example
Browse files Browse the repository at this point in the history
  • Loading branch information
metonym committed Apr 21, 2024
1 parent ccd7166 commit 50c5965
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion playground/src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,26 @@ export const forwarded_events = {
`,
};

export default [button, dynamic_dispatched_events, forwarded_events];
export const generics = {
moduleName: "Generics",
code: `<script>
/**
* @typedef {{ id: string | number; [key: string]: any; }} DataTableRow
* @typedef {Exclude<keyof Row, "id">} DataTableKey<Row>
* @typedef {{ key: DataTableKey<Row>; value: string; }} DataTableHeader<Row=DataTableRow>
* @template {DataTableRow} <Row extends DataTableRow = DataTableRow>
* @generics {Row extends DataTableRow = DataTableRow} Row
*/
/** @type {ReadonlyArray<DataTableHeader<Row>>} */
export let headers = [];
/** @type {ReadonlyArray<Row>} */
export let rows = [];
</script>
<slot {headers} {rows} />
`,
};

export default [button, dynamic_dispatched_events, forwarded_events, generics];

0 comments on commit 50c5965

Please sign in to comment.