diff --git a/guides/release/typescript/core-concepts/invokables.md b/guides/release/typescript/core-concepts/invokables.md index e14f50083a..6040d71d2b 100644 --- a/guides/release/typescript/core-concepts/invokables.md +++ b/guides/release/typescript/core-concepts/invokables.md @@ -643,50 +643,45 @@ Nearly anything you can do with a “regular” TypeScript function or class, yo We can make a component accept a [generic][generic] type, or use [union][union] types. With these tools at our disposal, we can even define our signatures to [make illegal states un-representable][illegal]. -To see this in practice, consider a list component which yields back out instances of the same type it provides, and provides the appropriate element target based on a `type` argument. -Yielding back out the same type passed in will use generics, and providing an appropriate element target for `...attributes` can use a union type. +### Union Types + +To see this in practice, consider a list component that provides the appropriate element target based on a `type` argument. Here is how that might look, using a class-backed component rather than a template-only component, since the only places TypeScript allows us to name new generic types are on functions and classes: -```typescript +```gts import Component from '@glimmer/component'; -interface OrderedList { +interface OrderedList { Args: { - items: Array; + names: Array; type: 'ordered'; }; - Blocks: { - default: [item: T]; - }; Element: HTMLOListElement; } -interface UnorderedList { +interface UnorderedList { Args: { - items: Array; + names: Array; type: 'unordered'; }; - Blocks: { - default: [item: T]; - }; Element: HTMLUListElement; } -type ListSignature = OrderedList | UnorderedList; +type ListSignature = OrderedList | UnorderedList; -export default class List extends Component> { +export default class List extends Component {