@@ -28,14 +28,25 @@ if (DEBUG) {
2828}
2929
3030// --- Type utilities for component signatures --- //
31-
32- // This provides us a way to have a "fallback" which represents an empty object,
33- // without the downsides of how TS treats `{}`. Specifically: this will
34- // correctly leverage "excess property checking" so that, given a component
35- // which has no named args, if someone invokes it with any named args, they will
36- // get a type error.
31+ // Type-only "symbol" to use with `EmptyObject` below, so that it is *not*
32+ // equivalent to an empty interface.
3733declare const Empty : unique symbol ;
38- type EmptyObject = { [ Empty ] ?: true } ;
34+
35+ /**
36+ * This provides us a way to have a "fallback" which represents an empty object,
37+ * without the downsides of how TS treats `{}`. Specifically: this will
38+ * correctly leverage "excess property checking" so that, given a component
39+ * which has no named args, if someone invokes it with any named args, they will
40+ * get a type error.
41+ *
42+ * @internal This is exported so declaration emit works (if it were not emitted,
43+ * declarations which fall back to it would not wor). It is *not* intended for
44+ * public usage, and the specific mechanics it uses may change at any time.
45+ * The location of this export *is* part of the public API, because moving it
46+ * will cause existing declarations, but is not legal for end users to import
47+ * themselves, so ***DO NOT RELY ON IT***.
48+ */
49+ export type EmptyObject = { [ Empty ] ?: true } ;
3950
4051type GetOrElse < Obj , K , Fallback > = K extends keyof Obj ? Obj [ K ] : Fallback ;
4152
@@ -49,8 +60,18 @@ type ArgsFor<S> = 'Args' extends keyof S
4960 : { Named : S [ 'Args' ] ; Positional : [ ] }
5061 : { Named : EmptyObject ; Positional : [ ] } ;
5162
52- /** Given any allowed shorthand form of a signature, desugars it to its full expanded type */
53- type ExpandSignature < T > = {
63+ /**
64+ * Given any allowed shorthand form of a signature, desugars it to its full
65+ * expanded type.
66+ *
67+ * @internal This is only exported so we can avoid duplicating it in
68+ * [Glint](https://github.com/typed-ember/glint) or other such tooling. It is
69+ * *not* intended for public usage, and the specific mechanics it uses may
70+ * change at any time. Although the signature produced by is part of Glimmer's
71+ * public API the existence and mechanics of this specific symbol are *not*,
72+ * so ***DO NOT RELY ON IT***.
73+ */
74+ export type ExpandSignature < T > = {
5475 Element : GetOrElse < T , 'Element' , null > ;
5576 Args : keyof T extends 'Args' | 'Element' | 'Blocks' // Is this a `Signature`?
5677 ? ArgsFor < T > // Then use `Signature` args
0 commit comments