@glint/template 0.6.0 → 0.7.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/dsl/resolve.d.ts +3 -6
- package/-private/dsl/types.d.ts +13 -3
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DirectInvokable,
|
|
1
|
+
import { DirectInvokable, Invokable, Invoke, InvokeDirect } from '../integration';
|
|
2
|
+
import { ResolveOrReturn } from './types';
|
|
2
3
|
|
|
3
4
|
/*
|
|
4
5
|
* We have multiple ways of representing invokable values, dictated by certain constraints
|
|
@@ -45,8 +46,4 @@ export declare function resolve<Args extends unknown[], Instance extends Invokab
|
|
|
45
46
|
* value of the appropriate type.
|
|
46
47
|
*/
|
|
47
48
|
|
|
48
|
-
export declare
|
|
49
|
-
export declare function resolveOrReturn<Args extends unknown[], Instance extends Invokable>(
|
|
50
|
-
item: (new (...args: Args) => Instance) | null | undefined
|
|
51
|
-
): (...args: Parameters<Instance[typeof Invoke]>) => ReturnType<Instance[typeof Invoke]>;
|
|
52
|
-
export declare function resolveOrReturn<T>(item: T): (args: EmptyObject) => T;
|
|
49
|
+
export declare const resolveOrReturn: ResolveOrReturn<typeof resolve>;
|
package/-private/dsl/types.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { HasContext } from '@glint/template/-private/integration';
|
|
1
|
+
import { EmptyObject, HasContext } from '@glint/template/-private/integration';
|
|
2
2
|
|
|
3
3
|
type Constructor<T> = new (...args: any) => T;
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A utility for constructing the type of an environment's `resolveOrReturn` from
|
|
7
|
+
* the type of its `resolve` function.
|
|
8
|
+
*/
|
|
9
|
+
export type ResolveOrReturn<T> = T & (<U>(item: U) => (args: EmptyObject) => U);
|
|
10
|
+
|
|
5
11
|
/**
|
|
6
12
|
* Given a tag name, returns an appropriate `Element` subtype.
|
|
7
13
|
* NOTE: This will return a union for elements that exist both in HTML and SVG. Technically, this will be too permissive.
|
|
@@ -15,10 +21,14 @@ export type ElementForTagName<Name extends string> = Name extends keyof HTMLElem
|
|
|
15
21
|
: Element;
|
|
16
22
|
|
|
17
23
|
/**
|
|
18
|
-
* Given the instance type of a component backing class, produces the appropriate
|
|
24
|
+
* Given the constructor or instance type of a component backing class, produces the appropriate
|
|
19
25
|
* `TemplateContext` type for its template.
|
|
20
26
|
*/
|
|
21
|
-
export type ResolveContext<T> = T extends HasContext<infer Context>
|
|
27
|
+
export type ResolveContext<T> = T extends HasContext<infer Context>
|
|
28
|
+
? Context
|
|
29
|
+
: T extends Constructor<HasContext<infer Context>>
|
|
30
|
+
? Context
|
|
31
|
+
: unknown;
|
|
22
32
|
|
|
23
33
|
// This encompasses both @glimmer/runtime and @ember/template's notion of `SafeString`s,
|
|
24
34
|
// and this coverage is tested in `emit-value.test.ts`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glint/template",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"repository": "typed-ember/glint",
|
|
5
5
|
"description": "Type definitions to back typechecking for Glimmer templates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@glimmer/component": "^1.0.2",
|
|
20
20
|
"@glimmerx/component": "^0.4.2",
|
|
21
|
-
"@types/ember__component": "~
|
|
21
|
+
"@types/ember__component": "~4.0.0",
|
|
22
22
|
"expect-type": "0.11.0",
|
|
23
23
|
"sums-up": "^2.1.0"
|
|
24
24
|
},
|