@glint/template 1.7.5 → 1.7.7

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.
@@ -7,7 +7,9 @@ import {
7
7
  HasContext,
8
8
  InvokableInstance,
9
9
  TemplateContext,
10
+ Invokable,
10
11
  NamedArgs,
12
+ UnwrapNamedArgs,
11
13
  } from '../integration';
12
14
  import {
13
15
  AttributesForElement,
@@ -15,6 +17,7 @@ import {
15
17
  MathMlElementForTagName,
16
18
  SVGElementForTagName,
17
19
  } from './types';
20
+ import { MaybeNamed, PrebindArgs } from '../signature';
18
21
 
19
22
  /**
20
23
  * Used during emit to denote an object literal that corresponds
@@ -173,3 +176,36 @@ export declare function applyModifier(boundModifier: ModifierReturn): void;
173
176
  * syntax.
174
177
  */
175
178
  export declare function noop(value: unknown): void;
179
+
180
+ /*
181
+ * Pre-binds named args while preserving generic type parameters (#1068).
182
+ * Uses Args/T holistic capture instead of Named/Return decomposition.
183
+ * The keyword's old decomposing overloads validate arg types but erase T;
184
+ * this function preserves T but doesn't validate. The transform emits both
185
+ * via a comma expression so errors come from the keyword (mapped) and the
186
+ * result comes from here (T-preserving).
187
+ */
188
+ type BindNamedResult<Args, T, GivenNamed> =
189
+ // Named-only args (required or optional — handles double-currying)
190
+ Args extends [NamedArgs<infer Named>?]
191
+ ? (
192
+ ...named: MaybeNamed<
193
+ PrebindArgs<NonNullable<Named>, keyof GivenNamed & keyof UnwrapNamedArgs<Named>>
194
+ >
195
+ ) => T
196
+ : // Positional + named args
197
+ Args extends [...infer Positional, NamedArgs<infer Named>]
198
+ ? (
199
+ ...args: [
200
+ ...Positional,
201
+ ...MaybeNamed<
202
+ PrebindArgs<NonNullable<Named>, keyof GivenNamed & keyof UnwrapNamedArgs<Named>>
203
+ >,
204
+ ]
205
+ ) => T
206
+ : (...args: Args extends unknown[] ? Args : never) => T;
207
+
208
+ export declare function bindInvokable<Args extends unknown[], T, GivenNamed>(
209
+ invokable: (...args: Args) => T,
210
+ named: NamedArgs<GivenNamed>,
211
+ ): Invokable<BindNamedResult<Args, T, GivenNamed>>;
@@ -36,9 +36,14 @@ export type ModifierReturn = { [Modifier]: true };
36
36
  * Denotes that the associated entity may be invoked with the given
37
37
  * blocks, yielding params of the appropriate type.
38
38
  */
39
+ // The original conditional `El extends Element ? El : null` deferred for
40
+ // generic conditional types like `ElementFromTagName<T>` (#610). Replaced
41
+ // with `El extends null ? unknown : El` which only fires for literal null
42
+ // (not conditional types) and converts null → unknown for ComponentLike
43
+ // equivalence.
39
44
  export type ComponentReturn<BlockDefs, El = null> = {
40
45
  [Blocks]: BlockDefs;
41
- [Element]: El extends Element ? El : null;
46
+ [Element]: El extends null ? unknown : El;
42
47
  };
43
48
 
44
49
  /**
@@ -44,8 +44,14 @@ export type ComponentSignatureBlocks<S> = S extends { Blocks: infer Blocks }
44
44
  : {};
45
45
 
46
46
  /** Given a component signature `S`, get back the `Element` type. */
47
+ // The original `NonNullable<Element> extends never` check deferred for generic
48
+ // conditional types like ElementFromTagName<T>, collapsing them to unknown
49
+ // (#610). Using `Element extends null` instead only fires for literal null
50
+ // (preserving null → unknown for ComponentLike equivalence) without breaking
51
+ // conditional types — TypeScript can verify the deferred result still extends
52
+ // Element because neither branch of ElementFromTagName<T> is null.
47
53
  export type ComponentSignatureElement<S> = S extends { Element: infer Element }
48
- ? NonNullable<Element> extends never
54
+ ? Element extends null
49
55
  ? unknown
50
56
  : Element
51
57
  : unknown;
package/README.md CHANGED
@@ -4,3 +4,4 @@ This package contains type declarations used by other [glint] packages for perfo
4
4
 
5
5
  [glint]: https://github.com/typed-ember/glint
6
6
 
7
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glint/template",
3
- "version": "1.7.5",
3
+ "version": "1.7.7",
4
4
  "repository": "typed-ember/glint",
5
5
  "description": "Type definitions to back typechecking for Glimmer templates",
6
6
  "license": "MIT",