From 3be2c57be7e5983a3aafd9dc1175922abdb89bd3 Mon Sep 17 00:00:00 2001 From: Lukas Nys Date: Tue, 24 Oct 2023 15:54:48 +0200 Subject: [PATCH 1/2] docs: add TOC example to template-only-components.md --- docs/ember/template-only-components.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/ember/template-only-components.md b/docs/ember/template-only-components.md index 6df41ee59..feb1265f6 100644 --- a/docs/ember/template-only-components.md +++ b/docs/ember/template-only-components.md @@ -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 +import type { TOC } From '@ember/component/template-only'; + +interface ShoutSignature { + Element: HTMLDivElement; + Args: { message: string }; + Blocks: { + default: [shoutedMessage: string]; + }; +} + +declare const Shout: TOC; +export default Shout; +``` + Due to the way TypeScript works, it's not possible to have a generic signature for template-only components: ```typescript From 7cd1f953bcc120a4fd79d789b6703a6639c47f40 Mon Sep 17 00:00:00 2001 From: Lukas Nys Date: Tue, 24 Oct 2023 21:45:49 +0200 Subject: [PATCH 2/2] docs: add filename to example --- docs/ember/template-only-components.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/ember/template-only-components.md b/docs/ember/template-only-components.md index feb1265f6..c344b695a 100644 --- a/docs/ember/template-only-components.md +++ b/docs/ember/template-only-components.md @@ -28,6 +28,8 @@ Note that the runtime content of this module (effectively `export default templa Additionally, you can create a backing module using the `TOC` type, which is a convenience alias for `templateOnlyComponent`. +{% code title="app/components/shout.ts" %} + ```typescript import type { TOC } From '@ember/component/template-only'; @@ -43,6 +45,8 @@ declare const Shout: TOC; export default Shout; ``` +{% endcode %} + Due to the way TypeScript works, it's not possible to have a generic signature for template-only components: ```typescript