UNPKG

1.41 kBTypeScriptView Raw
1declare module '@ember/template-compiler/lib/types' {
2 import type {
3 ASTPluginEnvironment,
4 builders,
5 PrecompileOptions,
6 PrecompileOptionsWithLexicalScope,
7 } from '@glimmer/syntax';
8 export type Builders = typeof builders;
9 export type PluginFunc = NonNullable<
10 NonNullable<PrecompileOptionsWithLexicalScope['plugins']>['ast']
11 >[number];
12 export type LexicalScope = NonNullable<PrecompileOptionsWithLexicalScope['lexicalScope']>;
13 interface Plugins {
14 ast: PluginFunc[];
15 }
16 export interface EmberPrecompileOptions extends PrecompileOptions {
17 isProduction?: boolean;
18 moduleName?: string;
19 plugins?: Plugins;
20 lexicalScope?: LexicalScope;
21 /**
22 * This supports template blocks defined in class bodies.
23 *
24 * Manual form:
25 *
26 * ```ts
27 * class MyComponent {
28 * static {
29 * template(templateContent, {
30 * component: this,
31 * eval: () => eval(arguments[0])
32 * })
33 * }
34 * }
35 * ```
36 *
37 * GJS form (compiled to the manual form via `content-tag`):
38 *
39 * ```ts
40 * class MyComponent {
41 * <template>Template Content</template>
42 * }
43 * ```
44 */
45 component?: object;
46 eval?: (value: string) => unknown;
47 scope?: () => Record<string, unknown>;
48 }
49 export type EmberASTPluginEnvironment = ASTPluginEnvironment & EmberPrecompileOptions;
50 export {};
51}