@glint/ember-tsc 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -0
  3. package/bin/ember-tsc.js +4 -0
  4. package/bin/glint-language-server.js +2 -0
  5. package/lib/cli/run-volar-tsc.d.ts +2 -0
  6. package/lib/cli/run-volar-tsc.d.ts.map +1 -0
  7. package/lib/cli/run-volar-tsc.js +30 -0
  8. package/lib/cli/run-volar-tsc.js.map +1 -0
  9. package/lib/config/config.d.ts +15 -0
  10. package/lib/config/config.d.ts.map +1 -0
  11. package/lib/config/config.js +21 -0
  12. package/lib/config/config.js.map +1 -0
  13. package/lib/config/environment.d.ts +26 -0
  14. package/lib/config/environment.d.ts.map +1 -0
  15. package/lib/config/environment.js +96 -0
  16. package/lib/config/environment.js.map +1 -0
  17. package/lib/config/index.d.ts +17 -0
  18. package/lib/config/index.d.ts.map +1 -0
  19. package/lib/config/index.js +26 -0
  20. package/lib/config/index.js.map +1 -0
  21. package/lib/config/loader.d.ts +25 -0
  22. package/lib/config/loader.d.ts.map +1 -0
  23. package/lib/config/loader.js +110 -0
  24. package/lib/config/loader.js.map +1 -0
  25. package/lib/config/types.cjs +3 -0
  26. package/lib/config/types.cjs.map +1 -0
  27. package/lib/config/types.d.cts +60 -0
  28. package/lib/config/types.d.cts.map +1 -0
  29. package/lib/environment-ember-template-imports/-private/environment/common.d.ts +13 -0
  30. package/lib/environment-ember-template-imports/-private/environment/common.d.ts.map +1 -0
  31. package/lib/environment-ember-template-imports/-private/environment/common.js +2 -0
  32. package/lib/environment-ember-template-imports/-private/environment/common.js.map +1 -0
  33. package/lib/environment-ember-template-imports/-private/environment/index.d.ts +3 -0
  34. package/lib/environment-ember-template-imports/-private/environment/index.d.ts.map +1 -0
  35. package/lib/environment-ember-template-imports/-private/environment/index.js +76 -0
  36. package/lib/environment-ember-template-imports/-private/environment/index.js.map +1 -0
  37. package/lib/environment-ember-template-imports/-private/environment/preprocess.d.ts +4 -0
  38. package/lib/environment-ember-template-imports/-private/environment/preprocess.d.ts.map +1 -0
  39. package/lib/environment-ember-template-imports/-private/environment/preprocess.js +73 -0
  40. package/lib/environment-ember-template-imports/-private/environment/preprocess.js.map +1 -0
  41. package/lib/environment-ember-template-imports/-private/environment/transform.d.ts +4 -0
  42. package/lib/environment-ember-template-imports/-private/environment/transform.d.ts.map +1 -0
  43. package/lib/environment-ember-template-imports/-private/environment/transform.js +134 -0
  44. package/lib/environment-ember-template-imports/-private/environment/transform.js.map +1 -0
  45. package/lib/index.d.ts +7 -0
  46. package/lib/index.d.ts.map +1 -0
  47. package/lib/index.js +6 -0
  48. package/lib/index.js.map +1 -0
  49. package/lib/plugins/g-compiler-errors.d.ts +12 -0
  50. package/lib/plugins/g-compiler-errors.d.ts.map +1 -0
  51. package/lib/plugins/g-compiler-errors.js +58 -0
  52. package/lib/plugins/g-compiler-errors.js.map +1 -0
  53. package/lib/plugins/g-template-tag-symbols.d.ts +11 -0
  54. package/lib/plugins/g-template-tag-symbols.d.ts.map +1 -0
  55. package/lib/plugins/g-template-tag-symbols.js +48 -0
  56. package/lib/plugins/g-template-tag-symbols.js.map +1 -0
  57. package/lib/plugins/utils.d.ts +25 -0
  58. package/lib/plugins/utils.d.ts.map +1 -0
  59. package/lib/plugins/utils.js +63 -0
  60. package/lib/plugins/utils.js.map +1 -0
  61. package/lib/transform/diagnostics/augmentation.d.ts +4 -0
  62. package/lib/transform/diagnostics/augmentation.d.ts.map +1 -0
  63. package/lib/transform/diagnostics/augmentation.js +223 -0
  64. package/lib/transform/diagnostics/augmentation.js.map +1 -0
  65. package/lib/transform/diagnostics/index.d.ts +5 -0
  66. package/lib/transform/diagnostics/index.d.ts.map +1 -0
  67. package/lib/transform/diagnostics/index.js +2 -0
  68. package/lib/transform/diagnostics/index.js.map +1 -0
  69. package/lib/transform/index.d.ts +4 -0
  70. package/lib/transform/index.d.ts.map +1 -0
  71. package/lib/transform/index.js +2 -0
  72. package/lib/transform/index.js.map +1 -0
  73. package/lib/transform/template/code-features.d.ts +30 -0
  74. package/lib/transform/template/code-features.d.ts.map +1 -0
  75. package/lib/transform/template/code-features.js +26 -0
  76. package/lib/transform/template/code-features.js.map +1 -0
  77. package/lib/transform/template/glimmer-ast-mapping-tree.d.ts +80 -0
  78. package/lib/transform/template/glimmer-ast-mapping-tree.d.ts.map +1 -0
  79. package/lib/transform/template/glimmer-ast-mapping-tree.js +132 -0
  80. package/lib/transform/template/glimmer-ast-mapping-tree.js.map +1 -0
  81. package/lib/transform/template/inlining/index.d.ts +16 -0
  82. package/lib/transform/template/inlining/index.d.ts.map +1 -0
  83. package/lib/transform/template/inlining/index.js +21 -0
  84. package/lib/transform/template/inlining/index.js.map +1 -0
  85. package/lib/transform/template/inlining/tagged-strings.d.ts +8 -0
  86. package/lib/transform/template/inlining/tagged-strings.d.ts.map +1 -0
  87. package/lib/transform/template/inlining/tagged-strings.js +140 -0
  88. package/lib/transform/template/inlining/tagged-strings.js.map +1 -0
  89. package/lib/transform/template/map-template-contents.d.ts +121 -0
  90. package/lib/transform/template/map-template-contents.d.ts.map +1 -0
  91. package/lib/transform/template/map-template-contents.js +287 -0
  92. package/lib/transform/template/map-template-contents.js.map +1 -0
  93. package/lib/transform/template/rewrite-module.d.ts +22 -0
  94. package/lib/transform/template/rewrite-module.d.ts.map +1 -0
  95. package/lib/transform/template/rewrite-module.js +265 -0
  96. package/lib/transform/template/rewrite-module.js.map +1 -0
  97. package/lib/transform/template/scope-stack.d.ts +13 -0
  98. package/lib/transform/template/scope-stack.d.ts.map +1 -0
  99. package/lib/transform/template/scope-stack.js +28 -0
  100. package/lib/transform/template/scope-stack.js.map +1 -0
  101. package/lib/transform/template/template-to-typescript.d.ts +19 -0
  102. package/lib/transform/template/template-to-typescript.d.ts.map +1 -0
  103. package/lib/transform/template/template-to-typescript.js +1095 -0
  104. package/lib/transform/template/template-to-typescript.js.map +1 -0
  105. package/lib/transform/template/transformed-module.d.ts +111 -0
  106. package/lib/transform/template/transformed-module.d.ts.map +1 -0
  107. package/lib/transform/template/transformed-module.js +287 -0
  108. package/lib/transform/template/transformed-module.js.map +1 -0
  109. package/lib/transform/util.d.ts +7 -0
  110. package/lib/transform/util.d.ts.map +1 -0
  111. package/lib/transform/util.js +15 -0
  112. package/lib/transform/util.js.map +1 -0
  113. package/lib/volar/ember-language-plugin.d.ts +14 -0
  114. package/lib/volar/ember-language-plugin.d.ts.map +1 -0
  115. package/lib/volar/ember-language-plugin.js +91 -0
  116. package/lib/volar/ember-language-plugin.js.map +1 -0
  117. package/lib/volar/gts-virtual-code.d.ts +83 -0
  118. package/lib/volar/gts-virtual-code.d.ts.map +1 -0
  119. package/lib/volar/gts-virtual-code.js +210 -0
  120. package/lib/volar/gts-virtual-code.js.map +1 -0
  121. package/lib/volar/language-server.d.ts +2 -0
  122. package/lib/volar/language-server.d.ts.map +1 -0
  123. package/lib/volar/language-server.js +214 -0
  124. package/lib/volar/language-server.js.map +1 -0
  125. package/lib/volar/script-snapshot.d.ts +17 -0
  126. package/lib/volar/script-snapshot.d.ts.map +1 -0
  127. package/lib/volar/script-snapshot.js +24 -0
  128. package/lib/volar/script-snapshot.js.map +1 -0
  129. package/package.json +104 -0
  130. package/src/cli/run-volar-tsc.ts +36 -0
  131. package/src/config/config.ts +33 -0
  132. package/src/config/environment.ts +128 -0
  133. package/src/config/index.ts +30 -0
  134. package/src/config/loader.ts +143 -0
  135. package/src/config/types.cts +85 -0
  136. package/src/environment-ember-template-imports/-private/environment/common.ts +14 -0
  137. package/src/environment-ember-template-imports/-private/environment/index.ts +83 -0
  138. package/src/environment-ember-template-imports/-private/environment/preprocess.ts +90 -0
  139. package/src/environment-ember-template-imports/-private/environment/transform.ts +202 -0
  140. package/src/index.ts +9 -0
  141. package/src/plugins/g-compiler-errors.ts +67 -0
  142. package/src/plugins/g-template-tag-symbols.ts +54 -0
  143. package/src/plugins/utils.ts +86 -0
  144. package/src/transform/diagnostics/augmentation.ts +333 -0
  145. package/src/transform/diagnostics/index.ts +5 -0
  146. package/src/transform/index.ts +4 -0
  147. package/src/transform/template/code-features.ts +30 -0
  148. package/src/transform/template/glimmer-ast-mapping-tree.ts +173 -0
  149. package/src/transform/template/inlining/index.ts +33 -0
  150. package/src/transform/template/inlining/tagged-strings.ts +187 -0
  151. package/src/transform/template/map-template-contents.ts +501 -0
  152. package/src/transform/template/rewrite-module.ts +372 -0
  153. package/src/transform/template/scope-stack.ts +34 -0
  154. package/src/transform/template/template-to-typescript.ts +1476 -0
  155. package/src/transform/template/transformed-module.ts +431 -0
  156. package/src/transform/util.ts +24 -0
  157. package/src/volar/ember-language-plugin.ts +108 -0
  158. package/src/volar/gts-virtual-code.ts +249 -0
  159. package/src/volar/language-server.ts +250 -0
  160. package/src/volar/script-snapshot.ts +27 -0
  161. package/types/-private/dsl/globals.d.ts +204 -0
  162. package/types/-private/dsl/index.d.ts +50 -0
  163. package/types/-private/dsl/integration-declarations.d.ts +143 -0
  164. package/types/-private/intrinsics/action.d.ts +45 -0
  165. package/types/-private/intrinsics/concat.d.ts +6 -0
  166. package/types/-private/intrinsics/each-in.d.ts +24 -0
  167. package/types/-private/intrinsics/each.d.ts +17 -0
  168. package/types/-private/intrinsics/fn.d.ts +44 -0
  169. package/types/-private/intrinsics/get.d.ts +31 -0
  170. package/types/-private/intrinsics/input.d.ts +24 -0
  171. package/types/-private/intrinsics/link-to.d.ts +31 -0
  172. package/types/-private/intrinsics/log.d.ts +6 -0
  173. package/types/-private/intrinsics/mount.d.ts +9 -0
  174. package/types/-private/intrinsics/mut.d.ts +14 -0
  175. package/types/-private/intrinsics/on.d.ts +21 -0
  176. package/types/-private/intrinsics/outlet.d.ts +8 -0
  177. package/types/-private/intrinsics/textarea.d.ts +16 -0
  178. package/types/-private/intrinsics/unbound.d.ts +10 -0
  179. package/types/-private/intrinsics/unique-id.d.ts +5 -0
  180. package/types/globals/index.d.ts +3 -0
  181. package/types/silent-error.d.ts +4 -0
@@ -0,0 +1,204 @@
1
+ import Globals from '../../globals';
2
+
3
+ import * as VM from '@glint/template/-private/keywords';
4
+
5
+ import { ActionKeyword } from '../intrinsics/action';
6
+ import { EachKeyword } from '../intrinsics/each';
7
+ import { EachInKeyword } from '../intrinsics/each-in';
8
+ import { LogHelper } from '../intrinsics/log';
9
+ import { MountKeyword } from '../intrinsics/mount';
10
+ import { MutKeyword } from '../intrinsics/mut';
11
+ import { OutletKeyword } from '../intrinsics/outlet';
12
+ import { UnboundKeyword } from '../intrinsics/unbound';
13
+ import { UniqueIdHelper } from '../intrinsics/unique-id';
14
+
15
+ // The keyword vs global breakdown here is loosely matched with
16
+ // the listing in http://emberjs.github.io/rfcs/0496-handlebars-strict-mode.html
17
+
18
+ interface Keywords {
19
+ /**
20
+ The {{action}} helper provides a way to pass triggers for behavior (usually just a function)
21
+ between components, and into components from controllers.
22
+
23
+ See [the API documentation] for further details.
24
+
25
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/action?anchor=action
26
+ */
27
+ action: ActionKeyword;
28
+
29
+ /**
30
+ The `{{component}}` helper lets you add instances of `Component` to a template.
31
+ `{{component}}`'s primary use is for cases where you want to dynamically change
32
+ which type of component is rendered as the state of your application changes.
33
+
34
+ See [the API documentation] for further details.
35
+
36
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/component?anchor=component
37
+ */
38
+ component: VM.ComponentKeyword;
39
+
40
+ /**
41
+ Execute the `debugger` statement in the current template's context.
42
+
43
+ See [the API documentation] for further details.
44
+
45
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/debugger?anchor=debugger
46
+ */
47
+ debugger: VM.DebuggerKeyword;
48
+
49
+ /**
50
+ The `{{#each}}` helper loops over elements in a collection.
51
+
52
+ See [the API documentation] for further details.
53
+
54
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/each?anchor=each
55
+ */
56
+ each: EachKeyword;
57
+
58
+ /**
59
+ The `{{each-in}}` helper loops over properties on an object.
60
+
61
+ See [the API documentation] for further details.
62
+
63
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/each-in?anchor=each-in
64
+ */
65
+ 'each-in': EachInKeyword;
66
+
67
+ /**
68
+ `{{has-block}}` indicates if the component was invoked with a block.
69
+
70
+ See [the API documentation] for further details.
71
+
72
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/hasBlock?anchor=hasBlock
73
+ */
74
+ 'has-block': VM.HasBlockKeyword;
75
+
76
+ /**
77
+ `{{has-block-params}}` indicates if the component was invoked with block params.
78
+
79
+ See [the API documentation] for further details.
80
+
81
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/hasBlockParams?anchor=hasBlockParams
82
+ */
83
+ 'has-block-params': VM.HasBlockParamsKeyword;
84
+
85
+ /**
86
+ Use the `{{helper}}` helper to create a contextual helper so that it can be passed
87
+ around as first-class values in templates.
88
+
89
+ See [the API documentation] for further details.
90
+
91
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/helper?anchor=helper
92
+ */
93
+ helper: VM.HelperKeyword;
94
+
95
+ // `{{if}}` is implemented directly in `ember-tsc`
96
+ if: void;
97
+
98
+ /**
99
+ The `{{in-element}}` helper renders its block content outside of the regular flow,
100
+ into a DOM element given by its `destinationElement` positional argument.
101
+
102
+ See [the API documentation] for further details.
103
+
104
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/in-element?anchor=in-element
105
+ */
106
+ 'in-element': VM.InElementKeyword;
107
+
108
+ /**
109
+ The `{{let}}` helper receives one or more positional arguments and yields
110
+ them out as block params.
111
+
112
+ See [the API documentation] for further details.
113
+
114
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/let?anchor=let
115
+ */
116
+ let: VM.LetKeyword;
117
+
118
+ /**
119
+ `log` allows you to output the value of variables in the current rendering
120
+ context.
121
+
122
+ See [the API documentation] for further details.
123
+
124
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/log?anchor=log
125
+ */
126
+ log: LogHelper;
127
+
128
+ /**
129
+ Use the `{{modifier}}` helper to create a contextual modifier so that it can be passed
130
+ around as first-class values in templates.
131
+
132
+ See [the API documentation] for further details.
133
+
134
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/modifier?anchor=modifier
135
+ */
136
+ modifier: VM.ModifierKeyword;
137
+
138
+ /**
139
+ The `{{mount}}` helper lets you embed a routeless engine in a template.
140
+
141
+ See [the API documentation] for further details.
142
+
143
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/mount?anchor=mount
144
+ ```
145
+ */
146
+ mount: MountKeyword;
147
+
148
+ /**
149
+ The `mut` helper, when used with `fn`, will return a function that
150
+ sets the value passed to `mut` to its first argument.
151
+
152
+ See [the API documentation] for further details.
153
+
154
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/mut?anchor=mut
155
+ */
156
+ mut: MutKeyword;
157
+
158
+ /**
159
+ The `{{outlet}}` helper lets you specify where a child route will render in
160
+ your template.
161
+
162
+ See [the API documentation] for further details.
163
+
164
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/outlet?anchor=outlet
165
+ */
166
+ outlet: OutletKeyword;
167
+
168
+ /**
169
+ The `{{unbound}}` helper disconnects the one-way binding of a property,
170
+ essentially freezing its value at the moment of rendering.
171
+
172
+ See [the API documentation] for further details.
173
+
174
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/unbound?anchor=unbound
175
+ */
176
+ unbound: UnboundKeyword;
177
+
178
+ /**
179
+ Use the `{{unique-id}}` helper to generate a unique ID string suitable for use as an ID
180
+ attribute in the DOM.
181
+
182
+ See [the API documentation] for further details.
183
+
184
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/unique-id?anchor=unique-id
185
+ */
186
+ 'unique-id': UniqueIdHelper;
187
+
188
+ // `{{unless}}` is implemented directly in `ember-tsc`
189
+ unless: void;
190
+
191
+ /**
192
+ Use the `{{with}}` helper when you want to alias a property to a new name.
193
+
194
+ See [the API documentation] for further details.
195
+
196
+ [the API documentation]: https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/with?anchor=with
197
+ */
198
+ with: VM.WithKeyword;
199
+
200
+ // `{{yield}}` is implemented directly in `ember-tsc`
201
+ yield: void;
202
+ }
203
+
204
+ export const Globals: Keywords & Globals;
@@ -0,0 +1,50 @@
1
+ // Reference the scaffolding for our merged declarations for third party modules so
2
+ // that vanilla TS will see those as long as authors have
3
+ // `import '@glint/ember-tsc/environment-ember-template-imports'` somewhere in their project.
4
+
5
+ /// <reference path="../../globals/index.d.ts" preserve="true" />
6
+ /// <reference path="./integration-declarations.d.ts" preserve="true" />
7
+
8
+ export * from '@glint/template/-private/dsl';
9
+ export { Globals } from './globals';
10
+
11
+ import { ResolveOrReturn } from '@glint/template/-private/dsl';
12
+ import {
13
+ AnyContext,
14
+ AnyFunction,
15
+ ComponentReturn,
16
+ DirectInvokable,
17
+ HasContext,
18
+ InvokableInstance,
19
+ Invoke,
20
+ InvokeDirect,
21
+ TemplateContext,
22
+ } from '@glint/template/-private/integration';
23
+
24
+ // Items that can be directly invoked by value
25
+ export declare function resolve<T extends DirectInvokable>(item: T): T[typeof InvokeDirect];
26
+ // Items whose instance type can be invoked
27
+ export declare function resolve<Args extends unknown[], Instance extends InvokableInstance>(
28
+ item: (abstract new (...args: Args) => Instance) | null | undefined,
29
+ ): (...args: Parameters<Instance[typeof Invoke]>) => ReturnType<Instance[typeof Invoke]>;
30
+ // Plain functions
31
+ export declare function resolve<T extends ((...params: any) => any) | null | undefined>(
32
+ item: T,
33
+ ): NonNullable<T>;
34
+
35
+ export declare const resolveOrReturn: ResolveOrReturn<typeof resolve>;
36
+
37
+ // We customize the top-level `templateExpression` wrapper function for this environment to
38
+ // return a type that's assignable to `TemplateOnlyComponent` from '@ember/component/template-only'.
39
+ // Longer term we should rationalize this to a type that doesn't carry extra baggage
40
+ // and likely comes from a more sensible path.
41
+
42
+ import { TemplateOnlyComponent } from '@ember/component/template-only';
43
+
44
+ export declare function templateExpression<
45
+ Signature extends AnyFunction = () => ComponentReturn<{}>,
46
+ Context extends AnyContext = TemplateContext<void, {}, {}, void>,
47
+ >(
48
+ f: (__glintRef__: Context, __glintDSL__: never) => void,
49
+ ): TemplateOnlyComponent<never> &
50
+ (abstract new () => InvokableInstance<Signature> & HasContext<Context>);
@@ -0,0 +1,143 @@
1
+ // This module is responsible for augmenting the upstream definitions of entities that interact
2
+ // with templates to include the information necessary for Glint to typecheck them.
3
+
4
+ import { ComponentLike, HelperLike, ModifierLike } from '@glint/template';
5
+ import {
6
+ Context,
7
+ FlattenBlockParams,
8
+ HasContext,
9
+ TemplateContext,
10
+ } from '@glint/template/-private/integration';
11
+ import {
12
+ ComponentSignatureArgs,
13
+ ComponentSignatureBlocks,
14
+ ComponentSignatureElement,
15
+ } from '@glint/template/-private/signature';
16
+
17
+ //////////////////////////////////////////////////////////////////////
18
+ // Components
19
+
20
+ import '@ember/component';
21
+ import '@ember/component/template-only';
22
+ import '@glimmer/component';
23
+
24
+ type ComponentContext<This, S> = TemplateContext<
25
+ This,
26
+ ComponentSignatureArgs<S>['Named'],
27
+ FlattenBlockParams<ComponentSignatureBlocks<S>>,
28
+ ComponentSignatureElement<S>
29
+ >;
30
+
31
+ declare module '@glimmer/component' {
32
+ export default interface Component<S> extends InstanceType<ComponentLike<S>> {
33
+ [Context]: ComponentContext<this, S>;
34
+ }
35
+ }
36
+
37
+ import { InputComponent as ImportedInputComponent } from '../intrinsics/input';
38
+ import { TextareaComponent as ImportedTextareaComponent } from '../intrinsics/textarea';
39
+ declare module '@ember/component' {
40
+ export default interface Component<S> extends InstanceType<ComponentLike<S>> {
41
+ [Context]: ComponentContext<this, S>;
42
+ }
43
+ export interface Textarea extends ImportedTextareaComponent {}
44
+ export interface Input extends ImportedInputComponent {}
45
+ }
46
+
47
+ interface TemplateOnlyComponentInstance<S> extends InstanceType<ComponentLike<S>> {
48
+ [Context]: ComponentContext<null, S>;
49
+ }
50
+
51
+ // As with other abstract constructor types, this allows us to provide a class
52
+ // and therefore have InstanceType work as needed, while forbidding construction
53
+ // by end users.
54
+ type TemplateOnlyConstructor<S> = abstract new () => TemplateOnlyComponentInstance<S>;
55
+
56
+ declare module '@ember/component/template-only' {
57
+ export interface TemplateOnlyComponent<S> extends TemplateOnlyConstructor<S> {}
58
+ }
59
+
60
+ //////////////////////////////////////////////////////////////////////
61
+ // Helpers
62
+
63
+ import '@ember/component/helper';
64
+
65
+ declare module '@ember/component/helper' {
66
+ export default interface Helper<S> extends InstanceType<HelperLike<S>> {}
67
+ }
68
+
69
+ //////////////////////////////////////////////////////////////////////
70
+ // Modifiers
71
+
72
+ import 'ember-modifier';
73
+
74
+ declare module 'ember-modifier' {
75
+ export default interface ClassBasedModifier<S> extends InstanceType<ModifierLike<S>> {}
76
+ }
77
+
78
+ //////////////////////////////////////////////////////////////////////
79
+ // Routes and Controllers
80
+
81
+ import Controller from '@ember/controller';
82
+ import Route from '@ember/routing/route';
83
+
84
+ type ModelForRoute<T extends Route> = Awaited<ReturnType<T['model']>>;
85
+ type ModelField<T> = { model: T };
86
+
87
+ declare module '@ember/routing/route' {
88
+ export default interface Route {
89
+ [Context]: TemplateContext<
90
+ Controller & ModelField<ModelForRoute<this>>,
91
+ ModelField<ModelForRoute<this>>,
92
+ {},
93
+ null
94
+ >;
95
+ }
96
+ }
97
+
98
+ declare module '@ember/controller' {
99
+ export default interface Controller {
100
+ [Context]: TemplateContext<this, ModelField<this['model']>, {}, null>;
101
+ }
102
+ }
103
+
104
+ import { LinkToComponent } from '../intrinsics/link-to';
105
+ declare module '@ember/routing' {
106
+ export interface LinkTo extends LinkToComponent {}
107
+ }
108
+
109
+ //////////////////////////////////////////////////////////////////////
110
+ // Rendering Tests
111
+
112
+ import '@ember/test-helpers';
113
+ import 'ember-cli-htmlbars';
114
+
115
+ type TestTemplate<T> = abstract new () => HasContext<TemplateContext<T, {}, {}, void>>;
116
+
117
+ declare module '@ember/test-helpers' {
118
+ export function render<T>(template: TestTemplate<T>): Promise<void>;
119
+ }
120
+
121
+ // Declaring that `TemplateFactory` is a valid `TestTemplate` prevents vanilla `tsc` from freaking out
122
+ // about `hbs` not returning a valid type for `render`. Glint itself will never see `hbs` get used, as
123
+ // it's transformed to the template DSL before typechecking.
124
+ declare module 'ember-cli-htmlbars' {
125
+ interface TemplateFactory extends TestTemplate<any> {}
126
+ }
127
+
128
+ import '@ember/modifier';
129
+ import { OnModifier as ImportedOnModifier } from '../intrinsics/on';
130
+ declare module '@ember/modifier' {
131
+ export interface OnModifier extends ImportedOnModifier {}
132
+ }
133
+
134
+ import '@ember/helper';
135
+ import { ConcatHelper as ImportedConcatHelper } from '../intrinsics/concat';
136
+ import { FnHelper as ImportedFnHelper } from '../intrinsics/fn';
137
+ import { GetHelper as ImportedGetHelper } from '../intrinsics/get';
138
+
139
+ declare module '@ember/helper' {
140
+ export interface ConcatHelper extends ImportedConcatHelper {}
141
+ export interface FnHelper extends ImportedFnHelper {}
142
+ export interface GetHelper extends ImportedGetHelper {}
143
+ }
@@ -0,0 +1,45 @@
1
+ import { DirectInvokable, NamedArgs } from '@glint/template/-private/integration';
2
+
3
+ export type ActionNamedArgs<T> = NamedArgs<{
4
+ value?: keyof T;
5
+ }>;
6
+
7
+ export type ActionResult<T, Args extends ActionNamedArgs<T>> = undefined extends Args['value']
8
+ ? T
9
+ : Args['value'] extends keyof T
10
+ ? T[Args['value']]
11
+ : T;
12
+
13
+ export type ActionKeyword = DirectInvokable<{
14
+ <Ret, Args extends ActionNamedArgs<Ret>, Params extends unknown[]>(
15
+ f: (...rest: Params) => Ret,
16
+ args?: Args,
17
+ ): (...rest: Params) => ActionResult<Ret, Args>;
18
+ <A, Ret, Args extends ActionNamedArgs<Ret>, Params extends unknown[]>(
19
+ f: (a: A, ...rest: Params) => Ret,
20
+ a: A,
21
+ args?: Args,
22
+ ): (...rest: Params) => ActionResult<Ret, Args>;
23
+ <A, B, Ret, Args extends ActionNamedArgs<Ret>, Params extends unknown[]>(
24
+ f: (a: A, b: B, ...rest: Params) => Ret,
25
+ a: A,
26
+ b: B,
27
+ args?: Args,
28
+ ): (...rest: Params) => ActionResult<Ret, Args>;
29
+ <A, B, C, Ret, Args extends ActionNamedArgs<Ret>, Params extends unknown[]>(
30
+ f: (a: A, b: B, c: C, ...rest: Params) => Ret,
31
+ a: A,
32
+ b: B,
33
+ c: C,
34
+ args?: Args,
35
+ ): (...rest: Params) => ActionResult<Ret, Args>;
36
+ <A, B, C, D, Ret, Args extends ActionNamedArgs<Ret>, Params extends unknown[]>(
37
+ f: (a: A, b: B, c: C, d: D, ...rest: Params) => Ret,
38
+ a: A,
39
+ b: B,
40
+ c: C,
41
+ d: D,
42
+ args?: Args,
43
+ ): (...rest: Params) => ActionResult<Ret, Args>;
44
+ (action: string, ...rest: unknown[]): (...rest: unknown[]) => unknown;
45
+ }>;
@@ -0,0 +1,6 @@
1
+ import { HelperLike } from '@glint/template';
2
+
3
+ export type ConcatHelper = HelperLike<{
4
+ Args: { Positional: unknown[] };
5
+ Return: string;
6
+ }>;
@@ -0,0 +1,24 @@
1
+ import { ComponentLike } from '@glint/template';
2
+
3
+ export type EachInKeyword = abstract new <T>() => InstanceType<
4
+ ComponentLike<{
5
+ Args: {
6
+ Positional: [object: T];
7
+ Named: { key?: string };
8
+ };
9
+ Blocks: {
10
+ default: EachInIteratorPair<T>;
11
+ else?: [];
12
+ };
13
+ }>
14
+ >;
15
+
16
+ type EachInIteratorPair<T> =
17
+ T extends Iterable<[infer K, infer V]>
18
+ ? [key: K, value: V]
19
+ : [key: EachInKey<T>, value: Exclude<T, null | undefined>[EachInKey<T>]];
20
+
21
+ // `{{each-in}}` internally uses `Object.keys`, so only string keys are included
22
+ // TS, on the other hand, gives a wider result for `keyof` than many users expect
23
+ // for record types: https://github.com/microsoft/TypeScript/issues/29249
24
+ type EachInKey<T> = Extract<keyof Exclude<T, null | undefined>, string>;
@@ -0,0 +1,17 @@
1
+ import EmberArray from '@ember/array';
2
+ import { ComponentLike } from '@glint/template';
3
+
4
+ type ArrayLike<T> = ReadonlyArray<T> | Iterable<T> | EmberArray<T>;
5
+
6
+ export type EachKeyword = abstract new <T = any>() => InstanceType<
7
+ ComponentLike<{
8
+ Args: {
9
+ Positional: [items: ArrayLike<T> | null | undefined];
10
+ Named: { key?: string };
11
+ };
12
+ Blocks: {
13
+ default: [T, number];
14
+ else: [];
15
+ };
16
+ }>
17
+ >;
@@ -0,0 +1,44 @@
1
+ import { DirectInvokable } from '@glint/template/-private/integration';
2
+ import { Mut } from './mut';
3
+
4
+ export type FnHelper = DirectInvokable<{
5
+ <T>(update: Mut<T>): (value: T) => void;
6
+ <T>(update: Mut<T>, value: T): () => void;
7
+ <Ret, Args extends unknown[]>(f: (...rest: Args) => Ret): (...rest: Args) => Ret;
8
+ <A, Ret, Args extends unknown[]>(f: (a: A, ...rest: Args) => Ret, a: A): (...rest: Args) => Ret;
9
+ <A, B, Ret, Args extends unknown[]>(
10
+ f: (a: A, b: B, ...rest: Args) => Ret,
11
+ a: A,
12
+ b: B,
13
+ ): (...rest: Args) => Ret;
14
+ <A, B, C, Ret, Args extends unknown[]>(
15
+ f: (a: A, b: B, c: C, ...rest: Args) => Ret,
16
+ a: A,
17
+ b: B,
18
+ c: C,
19
+ ): (...rest: Args) => Ret;
20
+ <A, B, C, D, Ret, Args extends unknown[]>(
21
+ f: (a: A, b: B, c: C, d: D, ...rest: Args) => Ret,
22
+ a: A,
23
+ b: B,
24
+ c: C,
25
+ d: D,
26
+ ): (...rest: Args) => Ret;
27
+ <A, B, C, D, E, Ret, Args extends unknown[]>(
28
+ f: (a: A, b: B, c: C, d: D, e: E, ...rest: Args) => Ret,
29
+ a: A,
30
+ b: B,
31
+ c: C,
32
+ d: D,
33
+ e: E,
34
+ ): (...rest: Args) => Ret;
35
+ <A, B, C, D, E, G, Ret, Args extends unknown[]>(
36
+ f: (a: A, b: B, c: C, d: D, e: E, g: G, ...rest: Args) => Ret,
37
+ a: A,
38
+ b: B,
39
+ c: C,
40
+ d: D,
41
+ e: E,
42
+ g: G,
43
+ ): (...rest: Args) => Ret;
44
+ }>;
@@ -0,0 +1,31 @@
1
+ import { DirectInvokable } from '@glint/template/-private/integration';
2
+ import ObjectProxy from '@ember/object/proxy';
3
+ import '@ember/object/-private/types';
4
+
5
+ // This hack lets us support both the stable/preview types from `ember-source`
6
+ // and the classic types still live on DefinitelyTyped. If using the DT types,
7
+ // this acts as a declaration merge for a module which is then integrated via
8
+ // the rest of the DT types. If using the stable/preview types, this ends up
9
+ // being a no-op.
10
+ declare const GetSetMarker: unique symbol;
11
+ declare module '@ember/object/-private/types' {
12
+ interface ComputedPropertyMarker<Get, Set = Get> {
13
+ [GetSetMarker]: [Get, Set];
14
+ }
15
+ }
16
+
17
+ type UnwrapComputedPropertyGetter<T> = T extends { [GetSetMarker]: [infer U, any] } ? U : T;
18
+
19
+ export type GetHelper = DirectInvokable<{
20
+ <T, K extends keyof T>(obj: T, key: K): UnwrapComputedPropertyGetter<T[K]>;
21
+ <T, K extends keyof T>(
22
+ obj: T | null | undefined,
23
+ key: K,
24
+ ): UnwrapComputedPropertyGetter<T[K]> | undefined;
25
+ <T extends object, K extends keyof T>(
26
+ obj: ObjectProxy<T> | null | undefined,
27
+ key: K,
28
+ ): UnwrapComputedPropertyGetter<T[K]> | undefined;
29
+ (obj: null | undefined, key: string): undefined;
30
+ (obj: unknown, key: string): unknown;
31
+ }>;
@@ -0,0 +1,24 @@
1
+ import { ComponentLike } from '@glint/template';
2
+
3
+ export interface CheckboxInputArgs {
4
+ type: 'checkbox';
5
+ checked?: boolean | undefined;
6
+ }
7
+
8
+ export interface TextInputArgs {
9
+ type?: string | undefined;
10
+ value?: string | null | undefined;
11
+ enter?: ((value: string, event: KeyboardEvent) => void) | undefined;
12
+ 'insert-newline'?: ((value: string, event: KeyboardEvent) => void) | undefined;
13
+ 'escape-press'?: ((value: string, event: KeyboardEvent) => void) | undefined;
14
+ 'focus-in'?: ((value: string, event: FocusEvent) => void) | undefined;
15
+ 'focus-out'?: ((value: string, event: FocusEvent) => void) | undefined;
16
+ 'key-down'?: ((value: string, event: KeyboardEvent) => void) | undefined;
17
+ 'key-press'?: ((value: string, event: KeyboardEvent) => void) | undefined;
18
+ 'key-up'?: ((value: string, event: KeyboardEvent) => void) | undefined;
19
+ }
20
+
21
+ export type InputComponent = ComponentLike<{
22
+ Args: { Named: CheckboxInputArgs | TextInputArgs };
23
+ Element: HTMLInputElement;
24
+ }>;
@@ -0,0 +1,31 @@
1
+ import { ComponentLike } from '@glint/template';
2
+ import { ComponentReturn, DirectInvokable, NamedArgs } from '@glint/template/-private/integration';
3
+
4
+ type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &
5
+ {
6
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
7
+ }[Keys];
8
+
9
+ type LinkToArgs = RequireAtLeastOne<
10
+ {
11
+ route?: string;
12
+ model?: unknown;
13
+ models?: unknown[];
14
+ query?: Record<string, unknown>;
15
+ disabled?: boolean;
16
+ activeClass?: string;
17
+ 'current-when'?: string | boolean;
18
+ preventDefault?: boolean;
19
+ replace?: boolean;
20
+ tagName?: string;
21
+ },
22
+ 'route' | 'model' | 'models' | 'query'
23
+ >;
24
+
25
+ type LinkToReturn = ComponentReturn<{ default: [] }, HTMLAnchorElement>;
26
+
27
+ export type LinkToComponent = ComponentLike<{
28
+ Args: LinkToArgs;
29
+ Blocks: { default: [] };
30
+ Element: HTMLAnchorElement;
31
+ }>;
@@ -0,0 +1,6 @@
1
+ import { HelperLike } from '@glint/template';
2
+
3
+ export type LogHelper = HelperLike<{
4
+ Args: { Positional: unknown[] };
5
+ Return: void;
6
+ }>;
@@ -0,0 +1,9 @@
1
+ import { HelperLike } from '@glint/template';
2
+
3
+ export type MountKeyword = HelperLike<{
4
+ Args: {
5
+ Positional: [engine: string];
6
+ Named: { model?: unknown };
7
+ };
8
+ Return: void;
9
+ }>;
@@ -0,0 +1,14 @@
1
+ import { HelperLike } from '@glint/template';
2
+
3
+ declare const Mut: unique symbol;
4
+
5
+ export type Mut<T> = { [Mut]: (value: T) => void };
6
+
7
+ export type MutKeyword = abstract new <T>() => InstanceType<
8
+ HelperLike<{
9
+ Args: {
10
+ Positional: [value: T];
11
+ };
12
+ Return: Mut<T>;
13
+ }>
14
+ >;