@glint/template 0.7.5 → 0.9.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.
- package/-private/index.d.ts +6 -6
- package/-private/integration.d.ts +2 -7
- package/package.json +6 -3
package/-private/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
AcceptsBlocks,
|
|
3
3
|
AnyFunction,
|
|
4
4
|
BoundModifier,
|
|
5
|
-
|
|
5
|
+
GuardEmpty,
|
|
6
6
|
FlattenBlockParams,
|
|
7
7
|
Invokable,
|
|
8
8
|
} from './integration';
|
|
9
|
-
import { ExpandSignature } from '@glimmer/component
|
|
9
|
+
import { ExpandSignature } from '@glimmer/component/-private/component';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* A value that is invokable like a component in a template. In an
|
|
@@ -14,12 +14,12 @@ import { ExpandSignature } from '@glimmer/component/dist/types/addon/-private/co
|
|
|
14
14
|
* `GlimmerComponent` are examples of `ComponentLike` values, as are
|
|
15
15
|
* the values returned from the `{{component}}` helper.
|
|
16
16
|
*
|
|
17
|
-
* The `S` signature
|
|
17
|
+
* The `S` signature parameter here is of the same form as the one
|
|
18
18
|
* accepted by both the Ember and Glimmer `Component` base classes.
|
|
19
19
|
*/
|
|
20
20
|
export type ComponentLike<S = unknown> = InvokableConstructor<
|
|
21
21
|
(
|
|
22
|
-
named: ExpandSignature<S>['Args']['Named']
|
|
22
|
+
named: GuardEmpty<ExpandSignature<S>['Args']['Named']>,
|
|
23
23
|
...positional: ExpandSignature<S>['Args']['Positional']
|
|
24
24
|
) => AcceptsBlocks<
|
|
25
25
|
FlattenBlockParams<ExpandSignature<S>['Blocks']>,
|
|
@@ -89,7 +89,7 @@ export type WithBoundArgs<
|
|
|
89
89
|
>
|
|
90
90
|
? InvokableConstructor<
|
|
91
91
|
(
|
|
92
|
-
named: Omit<Named, BoundArgs> & Partial<Pick<Named, BoundArgs & keyof Named
|
|
92
|
+
named: GuardEmpty<Omit<Named, BoundArgs> & Partial<Pick<Named, BoundArgs & keyof Named>>>,
|
|
93
93
|
...positional: Positional
|
|
94
94
|
) => Result
|
|
95
95
|
>
|
|
@@ -109,6 +109,6 @@ type Constrain<T, Constraint, Otherwise = Constraint> = T extends Constraint ? T
|
|
|
109
109
|
// different layers of possible shorthand, but modifiers and helpers only have
|
|
110
110
|
// one structure they can specify their args in, so this utility is sufficient.
|
|
111
111
|
type InvokableArgs<S> = [
|
|
112
|
-
named: Get<Get<S, 'Args'>, 'Named'
|
|
112
|
+
named: GuardEmpty<Get<Get<S, 'Args'>, 'Named'>>,
|
|
113
113
|
...positional: Constrain<Get<Get<S, 'Args'>, 'Positional'>, Array<unknown>, []>
|
|
114
114
|
];
|
|
@@ -25,6 +25,7 @@ export type HasContext<T extends AnyContext = AnyContext> = { [Context]: T };
|
|
|
25
25
|
// special-cased in the type system not to trigger EPC.
|
|
26
26
|
declare const EmptyObject: unique symbol;
|
|
27
27
|
export type EmptyObject = { [EmptyObject]?: void };
|
|
28
|
+
export type GuardEmpty<T> = T extends any ? (keyof T extends never ? EmptyObject : T) : never;
|
|
28
29
|
|
|
29
30
|
declare const Element: unique symbol;
|
|
30
31
|
declare const Modifier: unique symbol;
|
|
@@ -53,16 +54,10 @@ export type TemplateContext<This, Args, Yields, Element> = {
|
|
|
53
54
|
element: Element;
|
|
54
55
|
};
|
|
55
56
|
|
|
56
|
-
// This is a workaround for the fact that @glimmer/component initially shipped
|
|
57
|
-
// with a bug that causes blocks to expand as `{ default: { Positional: [] } }` rather
|
|
58
|
-
// thatn `{ default: { Params: { Positional: [] } } }`. Once a fix is released,
|
|
59
|
-
// we can require at least that version starting in Glint 0.8 and drop this wrapper.
|
|
60
|
-
type MaybeBlockParams<T> = T | { Params: T };
|
|
61
|
-
|
|
62
57
|
/**
|
|
63
58
|
* Flattens the fully expanded signature format for Blocks down to a mapping from
|
|
64
59
|
* each block name to a corresponding tuple of parameter types.
|
|
65
60
|
*/
|
|
66
61
|
export type FlattenBlockParams<T> = {
|
|
67
|
-
[K in keyof T]: T[K] extends
|
|
62
|
+
[K in keyof T]: T[K] extends { Params: { Positional: infer U } } ? U : T[K];
|
|
68
63
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glint/template",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"repository": "typed-ember/glint",
|
|
5
5
|
"description": "Type definitions to back typechecking for Glimmer templates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,10 +15,13 @@
|
|
|
15
15
|
"-private",
|
|
16
16
|
"*.d.ts"
|
|
17
17
|
],
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@glimmer/component": "^1.1.2"
|
|
20
|
+
},
|
|
18
21
|
"devDependencies": {
|
|
19
|
-
"@glimmer/component": "^1.1.
|
|
22
|
+
"@glimmer/component": "^1.1.2",
|
|
20
23
|
"@glimmerx/component": "^0.4.2",
|
|
21
|
-
"@types/ember__component": "~4.0.
|
|
24
|
+
"@types/ember__component": "~4.0.8",
|
|
22
25
|
"expect-type": "0.11.0",
|
|
23
26
|
"sums-up": "^2.1.0"
|
|
24
27
|
},
|