@@ -9,7 +9,7 @@ import Component from '@glimmer/component';
9
9
// expect to be -- and this keeps us honest about the fact that if we *change*
10
10
// this import location, we've broken any existing declarations published using
11
11
// the current type signatures.
12
- import { EmptyObject } from '@glimmer/component/addon /-private/component' ;
12
+ import type { EmptyObject , ExpandSignature } from '@glimmer/component/-private/component' ;
13
13
14
14
declare let basicComponent : Component ;
15
15
expectTypeOf ( basicComponent ) . toHaveProperty ( 'args' ) ;
@@ -30,6 +30,12 @@ type LegacyArgs = {
30
30
const componentWithLegacyArgs = new Component < LegacyArgs > ( { } , { foo : 123 } ) ;
31
31
expectTypeOf ( componentWithLegacyArgs . args ) . toEqualTypeOf < Readonly < LegacyArgs > > ( ) ;
32
32
33
+ expectTypeOf < ExpandSignature < LegacyArgs > > ( ) . toEqualTypeOf < {
34
+ Args : { Named : LegacyArgs ; Positional : [ ] } ;
35
+ Element : null ;
36
+ Blocks : EmptyObject ;
37
+ } > ( ) ;
38
+
33
39
// Here, we are testing that the types propertly distribute over union types,
34
40
// generics which extend other types, etc.
35
41
// Here, we are testing that the types propertly distribute over union types,
@@ -44,6 +50,19 @@ const legacyArgsDistributiveB = new Component<LegacyArgsDistributive>(
44
50
) ;
45
51
expectTypeOf ( legacyArgsDistributiveB . args ) . toEqualTypeOf < Readonly < LegacyArgsDistributive > > ( ) ;
46
52
53
+ expectTypeOf < ExpandSignature < LegacyArgsDistributive > > ( ) . toEqualTypeOf <
54
+ | {
55
+ Args : { Named : { foo : number } ; Positional : [ ] } ;
56
+ Element : null ;
57
+ Blocks : EmptyObject ;
58
+ }
59
+ | {
60
+ Args : { Named : { bar : string ; baz : boolean } ; Positional : [ ] } ;
61
+ Element : null ;
62
+ Blocks : EmptyObject ;
63
+ }
64
+ > ( ) ;
65
+
47
66
interface ExtensibleLegacy < T > {
48
67
value : T ;
49
68
extras : boolean ;
@@ -67,6 +86,12 @@ interface ArgsOnly {
67
86
const componentWithArgsOnly = new Component < ArgsOnly > ( { } , { foo : 123 } ) ;
68
87
expectTypeOf ( componentWithArgsOnly . args ) . toEqualTypeOf < Readonly < LegacyArgs > > ( ) ;
69
88
89
+ expectTypeOf < ExpandSignature < ArgsOnly > > ( ) . toEqualTypeOf < {
90
+ Args : { Named : LegacyArgs ; Positional : [ ] } ;
91
+ Element : null ;
92
+ Blocks : EmptyObject ;
93
+ } > ( ) ;
94
+
70
95
interface ElementOnly {
71
96
Element : HTMLParagraphElement ;
72
97
}
@@ -75,6 +100,12 @@ const componentWithElOnly = new Component<ElementOnly>({}, {});
75
100
76
101
expectTypeOf ( componentWithElOnly . args ) . toEqualTypeOf < Readonly < EmptyObject > > ( ) ;
77
102
103
+ expectTypeOf < ExpandSignature < ElementOnly > > ( ) . toEqualTypeOf < {
104
+ Args : { Named : EmptyObject ; Positional : [ ] } ;
105
+ Element : HTMLParagraphElement ;
106
+ Blocks : EmptyObject ;
107
+ } > ( ) ;
108
+
78
109
interface Blocks {
79
110
default : [ name : string ] ;
80
111
inverse : [ ] ;
@@ -88,6 +119,23 @@ const componentWithBlockOnly = new Component<BlockOnlySig>({}, {});
88
119
89
120
expectTypeOf ( componentWithBlockOnly . args ) . toEqualTypeOf < Readonly < EmptyObject > > ( ) ;
90
121
122
+ expectTypeOf < ExpandSignature < BlockOnlySig > > ( ) . toEqualTypeOf < {
123
+ Args : { Named : EmptyObject ; Positional : [ ] } ;
124
+ Element : null ;
125
+ Blocks : {
126
+ default : {
127
+ Params : {
128
+ Positional : [ name : string ] ;
129
+ } ;
130
+ } ;
131
+ inverse : {
132
+ Params : {
133
+ Positional : [ ] ;
134
+ } ;
135
+ } ;
136
+ } ;
137
+ } > ( ) ;
138
+
91
139
interface ArgsAndBlocks {
92
140
Args : LegacyArgs ;
93
141
Blocks : Blocks ;
@@ -96,6 +144,23 @@ interface ArgsAndBlocks {
96
144
const componentwithArgsAndBlocks = new Component < ArgsAndBlocks > ( { } , { foo : 123 } ) ;
97
145
expectTypeOf ( componentwithArgsAndBlocks . args ) . toEqualTypeOf < Readonly < LegacyArgs > > ( ) ;
98
146
147
+ expectTypeOf < ExpandSignature < ArgsAndBlocks > > ( ) . toEqualTypeOf < {
148
+ Args : { Named : LegacyArgs ; Positional : [ ] } ;
149
+ Element : null ;
150
+ Blocks : {
151
+ default : {
152
+ Params : {
153
+ Positional : [ name : string ] ;
154
+ } ;
155
+ } ;
156
+ inverse : {
157
+ Params : {
158
+ Positional : [ ] ;
159
+ } ;
160
+ } ;
161
+ } ;
162
+ } > ( ) ;
163
+
99
164
interface ArgsAndEl {
100
165
Args : LegacyArgs ;
101
166
Element : HTMLParagraphElement ;
@@ -104,6 +169,12 @@ interface ArgsAndEl {
104
169
const componentwithArgsAndEl = new Component < ArgsAndEl > ( { } , { foo : 123 } ) ;
105
170
expectTypeOf ( componentwithArgsAndEl . args ) . toEqualTypeOf < Readonly < LegacyArgs > > ( ) ;
106
171
172
+ expectTypeOf < ExpandSignature < ArgsAndEl > > ( ) . toEqualTypeOf < {
173
+ Args : { Named : LegacyArgs ; Positional : [ ] } ;
174
+ Element : HTMLParagraphElement ;
175
+ Blocks : EmptyObject ;
176
+ } > ( ) ;
177
+
107
178
interface FullShortSig {
108
179
Args : LegacyArgs ;
109
180
Element : HTMLParagraphElement ;
@@ -113,6 +184,23 @@ interface FullShortSig {
113
184
const componentWithFullShortSig = new Component < FullShortSig > ( { } , { foo : 123 } ) ;
114
185
expectTypeOf ( componentWithFullShortSig . args ) . toEqualTypeOf < Readonly < LegacyArgs > > ( ) ;
115
186
187
+ expectTypeOf < ExpandSignature < FullShortSig > > ( ) . toEqualTypeOf < {
188
+ Args : { Named : LegacyArgs ; Positional : [ ] } ;
189
+ Element : HTMLParagraphElement ;
190
+ Blocks : {
191
+ default : {
192
+ Params : {
193
+ Positional : [ name : string ] ;
194
+ } ;
195
+ } ;
196
+ inverse : {
197
+ Params : {
198
+ Positional : [ ] ;
199
+ } ;
200
+ } ;
201
+ } ;
202
+ } > ( ) ;
203
+
116
204
interface FullLongSig {
117
205
Args : {
118
206
Named : LegacyArgs ;
@@ -130,3 +218,5 @@ interface FullLongSig {
130
218
131
219
const componentWithFullSig = new Component < FullLongSig > ( { } , { foo : 123 } ) ;
132
220
expectTypeOf ( componentWithFullSig . args ) . toEqualTypeOf < Readonly < LegacyArgs > > ( ) ;
221
+
222
+ expectTypeOf < ExpandSignature < FullLongSig > > ( ) . toEqualTypeOf < FullLongSig > ( ) ;
0 commit comments