@@ -9,7 +9,7 @@ import Component from '@glimmer/component';
99// expect to be -- and this keeps us honest about the fact that if we *change*
1010// this import location, we've broken any existing declarations published using
1111// the current type signatures.
12- import { EmptyObject } from '@glimmer/component/addon /-private/component' ;
12+ import type { EmptyObject , ExpandSignature } from '@glimmer/component/-private/component' ;
1313
1414declare let basicComponent : Component ;
1515expectTypeOf ( basicComponent ) . toHaveProperty ( 'args' ) ;
@@ -30,6 +30,12 @@ type LegacyArgs = {
3030const componentWithLegacyArgs = new Component < LegacyArgs > ( { } , { foo : 123 } ) ;
3131expectTypeOf ( componentWithLegacyArgs . args ) . toEqualTypeOf < Readonly < LegacyArgs > > ( ) ;
3232
33+ expectTypeOf < ExpandSignature < LegacyArgs > > ( ) . toEqualTypeOf < {
34+ Args : { Named : LegacyArgs ; Positional : [ ] } ;
35+ Element : null ;
36+ Blocks : EmptyObject ;
37+ } > ( ) ;
38+
3339// Here, we are testing that the types propertly distribute over union types,
3440// generics which extend other types, etc.
3541// Here, we are testing that the types propertly distribute over union types,
@@ -44,6 +50,19 @@ const legacyArgsDistributiveB = new Component<LegacyArgsDistributive>(
4450) ;
4551expectTypeOf ( legacyArgsDistributiveB . args ) . toEqualTypeOf < Readonly < LegacyArgsDistributive > > ( ) ;
4652
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+
4766interface ExtensibleLegacy < T > {
4867 value : T ;
4968 extras : boolean ;
@@ -67,6 +86,12 @@ interface ArgsOnly {
6786const componentWithArgsOnly = new Component < ArgsOnly > ( { } , { foo : 123 } ) ;
6887expectTypeOf ( componentWithArgsOnly . args ) . toEqualTypeOf < Readonly < LegacyArgs > > ( ) ;
6988
89+ expectTypeOf < ExpandSignature < ArgsOnly > > ( ) . toEqualTypeOf < {
90+ Args : { Named : LegacyArgs ; Positional : [ ] } ;
91+ Element : null ;
92+ Blocks : EmptyObject ;
93+ } > ( ) ;
94+
7095interface ElementOnly {
7196 Element : HTMLParagraphElement ;
7297}
@@ -75,6 +100,12 @@ const componentWithElOnly = new Component<ElementOnly>({}, {});
75100
76101expectTypeOf ( componentWithElOnly . args ) . toEqualTypeOf < Readonly < EmptyObject > > ( ) ;
77102
103+ expectTypeOf < ExpandSignature < ElementOnly > > ( ) . toEqualTypeOf < {
104+ Args : { Named : EmptyObject ; Positional : [ ] } ;
105+ Element : HTMLParagraphElement ;
106+ Blocks : EmptyObject ;
107+ } > ( ) ;
108+
78109interface Blocks {
79110 default : [ name : string ] ;
80111 inverse : [ ] ;
@@ -88,6 +119,23 @@ const componentWithBlockOnly = new Component<BlockOnlySig>({}, {});
88119
89120expectTypeOf ( componentWithBlockOnly . args ) . toEqualTypeOf < Readonly < EmptyObject > > ( ) ;
90121
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+
91139interface ArgsAndBlocks {
92140 Args : LegacyArgs ;
93141 Blocks : Blocks ;
@@ -96,6 +144,23 @@ interface ArgsAndBlocks {
96144const componentwithArgsAndBlocks = new Component < ArgsAndBlocks > ( { } , { foo : 123 } ) ;
97145expectTypeOf ( componentwithArgsAndBlocks . args ) . toEqualTypeOf < Readonly < LegacyArgs > > ( ) ;
98146
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+
99164interface ArgsAndEl {
100165 Args : LegacyArgs ;
101166 Element : HTMLParagraphElement ;
@@ -104,6 +169,12 @@ interface ArgsAndEl {
104169const componentwithArgsAndEl = new Component < ArgsAndEl > ( { } , { foo : 123 } ) ;
105170expectTypeOf ( componentwithArgsAndEl . args ) . toEqualTypeOf < Readonly < LegacyArgs > > ( ) ;
106171
172+ expectTypeOf < ExpandSignature < ArgsAndEl > > ( ) . toEqualTypeOf < {
173+ Args : { Named : LegacyArgs ; Positional : [ ] } ;
174+ Element : HTMLParagraphElement ;
175+ Blocks : EmptyObject ;
176+ } > ( ) ;
177+
107178interface FullShortSig {
108179 Args : LegacyArgs ;
109180 Element : HTMLParagraphElement ;
@@ -113,6 +184,23 @@ interface FullShortSig {
113184const componentWithFullShortSig = new Component < FullShortSig > ( { } , { foo : 123 } ) ;
114185expectTypeOf ( componentWithFullShortSig . args ) . toEqualTypeOf < Readonly < LegacyArgs > > ( ) ;
115186
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+
116204interface FullLongSig {
117205 Args : {
118206 Named : LegacyArgs ;
@@ -130,3 +218,5 @@ interface FullLongSig {
130218
131219const componentWithFullSig = new Component < FullLongSig > ( { } , { foo : 123 } ) ;
132220expectTypeOf ( componentWithFullSig . args ) . toEqualTypeOf < Readonly < LegacyArgs > > ( ) ;
221+
222+ expectTypeOf < ExpandSignature < FullLongSig > > ( ) . toEqualTypeOf < FullLongSig > ( ) ;
0 commit comments