@@ -24,12 +24,18 @@ describe('validate-output-dist-custom-element', () => {
2424
2525 const { config } = validateConfig ( userConfig , mockLoadConfigInit ( ) ) ;
2626 expect ( config . outputTargets ) . toEqual ( [
27+ {
28+ type : DIST_TYPES ,
29+ dir : defaultDistDir ,
30+ typesDir : path . join ( rootDir , 'dist' , 'types' ) ,
31+ } ,
2732 {
2833 type : DIST_CUSTOM_ELEMENTS ,
2934 copy : [ ] ,
3035 dir : defaultDistDir ,
3136 empty : true ,
3237 externalRuntime : true ,
38+ generateTypeDeclarations : true ,
3339 } ,
3440 ] ) ;
3541 } ) ;
@@ -38,6 +44,7 @@ describe('validate-output-dist-custom-element', () => {
3844 const outputTarget : d . OutputTargetDistCustomElements = {
3945 type : DIST_CUSTOM_ELEMENTS ,
4046 dir : distCustomElementsDir ,
47+ generateTypeDeclarations : false ,
4148 } ;
4249 userConfig . outputTargets = [ outputTarget ] ;
4350
@@ -49,6 +56,7 @@ describe('validate-output-dist-custom-element', () => {
4956 dir : path . join ( rootDir , distCustomElementsDir ) ,
5057 empty : true ,
5158 externalRuntime : true ,
59+ generateTypeDeclarations : false ,
5260 } ,
5361 ] ) ;
5462 } ) ;
@@ -58,6 +66,7 @@ describe('validate-output-dist-custom-element', () => {
5866 const outputTarget : d . OutputTargetDistCustomElements = {
5967 type : DIST_CUSTOM_ELEMENTS ,
6068 externalRuntime : false ,
69+ generateTypeDeclarations : false ,
6170 } ;
6271 userConfig . outputTargets = [ outputTarget ] ;
6372
@@ -69,6 +78,7 @@ describe('validate-output-dist-custom-element', () => {
6978 dir : defaultDistDir ,
7079 empty : true ,
7180 externalRuntime : false ,
81+ generateTypeDeclarations : false ,
7282 } ,
7383 ] ) ;
7484 } ) ;
@@ -78,6 +88,7 @@ describe('validate-output-dist-custom-element', () => {
7888 type : DIST_CUSTOM_ELEMENTS ,
7989 empty : undefined ,
8090 externalRuntime : false ,
91+ generateTypeDeclarations : false ,
8192 } ;
8293 userConfig . outputTargets = [ outputTarget ] ;
8394
@@ -89,6 +100,7 @@ describe('validate-output-dist-custom-element', () => {
89100 dir : defaultDistDir ,
90101 empty : true ,
91102 externalRuntime : false ,
103+ generateTypeDeclarations : false ,
92104 } ,
93105 ] ) ;
94106 } ) ;
@@ -99,6 +111,7 @@ describe('validate-output-dist-custom-element', () => {
99111 const outputTarget : d . OutputTargetDistCustomElements = {
100112 type : DIST_CUSTOM_ELEMENTS ,
101113 empty : false ,
114+ generateTypeDeclarations : false ,
102115 } ;
103116 userConfig . outputTargets = [ outputTarget ] ;
104117
@@ -110,6 +123,7 @@ describe('validate-output-dist-custom-element', () => {
110123 dir : defaultDistDir ,
111124 empty : false ,
112125 externalRuntime : true ,
126+ generateTypeDeclarations : false ,
113127 } ,
114128 ] ) ;
115129 } ) ;
@@ -119,6 +133,7 @@ describe('validate-output-dist-custom-element', () => {
119133 type : DIST_CUSTOM_ELEMENTS ,
120134 empty : false ,
121135 externalRuntime : undefined ,
136+ generateTypeDeclarations : false ,
122137 } ;
123138 userConfig . outputTargets = [ outputTarget ] ;
124139
@@ -130,12 +145,64 @@ describe('validate-output-dist-custom-element', () => {
130145 dir : defaultDistDir ,
131146 empty : false ,
132147 externalRuntime : true ,
148+ generateTypeDeclarations : false ,
133149 } ,
134150 ] ) ;
135151 } ) ;
136152 } ) ;
137153
138154 describe ( '"generateTypeDeclarations" field' , ( ) => {
155+ it ( 'defaults the "generateTypeDeclarations" field to true if not provided' , ( ) => {
156+ const outputTarget : d . OutputTargetDistCustomElements = {
157+ type : DIST_CUSTOM_ELEMENTS ,
158+ empty : false ,
159+ } ;
160+ userConfig . outputTargets = [ outputTarget ] ;
161+
162+ const { config } = validateConfig ( userConfig , mockLoadConfigInit ( ) ) ;
163+ expect ( config . outputTargets ) . toEqual ( [
164+ {
165+ type : DIST_TYPES ,
166+ dir : defaultDistDir ,
167+ typesDir : path . join ( rootDir , 'dist' , 'types' ) ,
168+ } ,
169+ {
170+ type : DIST_CUSTOM_ELEMENTS ,
171+ copy : [ ] ,
172+ dir : defaultDistDir ,
173+ empty : false ,
174+ externalRuntime : true ,
175+ generateTypeDeclarations : true ,
176+ } ,
177+ ] ) ;
178+ } ) ;
179+
180+ it ( 'defaults the "generateTypeDeclarations" field to true it\'s not a boolean' , ( ) => {
181+ const outputTarget : d . OutputTargetDistCustomElements = {
182+ type : DIST_CUSTOM_ELEMENTS ,
183+ empty : false ,
184+ generateTypeDeclarations : undefined ,
185+ } ;
186+ userConfig . outputTargets = [ outputTarget ] ;
187+
188+ const { config } = validateConfig ( userConfig , mockLoadConfigInit ( ) ) ;
189+ expect ( config . outputTargets ) . toEqual ( [
190+ {
191+ type : DIST_TYPES ,
192+ dir : defaultDistDir ,
193+ typesDir : path . join ( rootDir , 'dist' , 'types' ) ,
194+ } ,
195+ {
196+ type : DIST_CUSTOM_ELEMENTS ,
197+ copy : [ ] ,
198+ dir : defaultDistDir ,
199+ empty : false ,
200+ externalRuntime : true ,
201+ generateTypeDeclarations : true ,
202+ } ,
203+ ] ) ;
204+ } ) ;
205+
139206 it ( 'creates a types directory when "generateTypeDeclarations" is true' , ( ) => {
140207 const outputTarget : d . OutputTargetDistCustomElements = {
141208 type : DIST_CUSTOM_ELEMENTS ,
@@ -231,6 +298,7 @@ describe('validate-output-dist-custom-element', () => {
231298 dir : distCustomElementsDir ,
232299 empty : false ,
233300 externalRuntime : false ,
301+ generateTypeDeclarations : false ,
234302 } ;
235303 userConfig . outputTargets = [ outputTarget ] ;
236304
@@ -247,6 +315,7 @@ describe('validate-output-dist-custom-element', () => {
247315 dir : path . join ( rootDir , distCustomElementsDir ) ,
248316 empty : false ,
249317 externalRuntime : false ,
318+ generateTypeDeclarations : false ,
250319 } ,
251320 ] ) ;
252321 } ) ;
0 commit comments