Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add TOC example to template-only-components.md #640

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/ember/template-only-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ declare module '@glint/environment-ember-loose/registry' {

Note that the runtime content of this module (effectively `export default templateOnlyComponent();`) is exactly what Ember generates at build time when creating a backing module for a template-only component.

Additionally, you can create a backing module using the `TOC` type, which is a convenience alias for `templateOnlyComponent`.

```typescript
lukasnys marked this conversation as resolved.
Show resolved Hide resolved
import type { TOC } From '@ember/component/template-only';

interface ShoutSignature {
Element: HTMLDivElement;
Args: { message: string };
Blocks: {
default: [shoutedMessage: string];
};
}

declare const Shout: TOC<ShoutSignature>;
export default Shout;
```

Due to the way TypeScript works, it's not possible to have a generic signature for template-only components:

```typescript
Expand Down