@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.
- package/-private/dsl/emit.d.ts +36 -0
- package/-private/integration.d.ts +6 -1
- package/-private/signature.d.ts +7 -1
- package/README.md +1 -0
- package/package.json +1 -1
package/-private/dsl/emit.d.ts
CHANGED
|
@@ -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
|
|
46
|
+
[Element]: El extends null ? unknown : El;
|
|
42
47
|
};
|
|
43
48
|
|
|
44
49
|
/**
|
package/-private/signature.d.ts
CHANGED
|
@@ -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
|
-
?
|
|
54
|
+
? Element extends null
|
|
49
55
|
? unknown
|
|
50
56
|
: Element
|
|
51
57
|
: unknown;
|
package/README.md
CHANGED