UNPKG

2.15 kBTypeScriptView Raw
1declare module '@ember/component/template-only' {
2 /**
3 @module @ember/component/template-only
4 @public
5 */
6 /**
7 This utility function is used to declare a given component has no backing class. When the rendering engine detects this it
8 is able to perform a number of optimizations. Templates that are associated with `templateOnly()` will be rendered _as is_
9 without adding a wrapping `<div>` (or any of the other element customization behaviors of [@ember/component](/ember/release/classes/Component)).
10 Specifically, this means that the template will be rendered as "outer HTML".
11
12 In apps, this method will usually be inserted by build-time tooling the handles converting `.hbs` files into component Javascript modules and
13 would not be directly written by the application author.
14
15 Addons may want to use this method directly to ensure that a template-only component is treated consistently in all Ember versions (Ember versions
16 before 4.0 have a "template-only-glimmer-components" optional feature that causes a standalone `.hbs` file to be interpreted differently).
17
18 @example
19
20 ```js
21 import templateOnly from '@ember/component/template-only';
22
23 export default templateOnly();
24 ```
25
26 @public
27 @static
28 @method templateOnly
29 @param {String} moduleName the module name that the template only component represents, this will be used for debugging purposes
30 @for @ember/component/template-only
31 @category EMBER_GLIMMER_SET_COMPONENT_TEMPLATE
32 */
33 import { type Opaque } from '@ember/-internals/utility-types';
34 /**
35 * Template-only components have no backing class instance, so `this` in their
36 * templates is null. This means that you can only reference passed in arguments
37 * (e.g. `{{@arg}}`).
38 */
39 export interface TemplateOnlyComponent<S = unknown> extends Opaque<S> {}
40 /**
41 * A convenience alias for {@link TemplateOnlyComponent}
42 */
43 export type TOC<S> = TemplateOnlyComponent<S>;
44 const templateOnly: <S>(moduleName?: string, name?: string) => TemplateOnlyComponent<S>;
45 export default templateOnly;
46}