@@ -282,13 +282,18 @@ export function isPrimitive(type: CodeName): boolean {
282
282
|| type . className === 'Date' ;
283
283
}
284
284
285
- function specTypeToCodeType ( resourceContext : CodeName , type : string ) : CodeName {
285
+ /**
286
+ * @param resourceContext
287
+ * @param type the name of the type
288
+ * @param complexType whether the type is a complexType (true) or primitive type (false)
289
+ */
290
+ function specTypeToCodeType ( resourceContext : CodeName , type : string , complexType : boolean ) : CodeName {
286
291
if ( type . endsWith ( '[]' ) ) {
287
- const itemType = specTypeToCodeType ( resourceContext , type . slice ( 0 , - 2 ) ) ;
292
+ const itemType = specTypeToCodeType ( resourceContext , type . slice ( 0 , - 2 ) , complexType ) ;
288
293
return CodeName . forPrimitive ( `${ itemType . className } []` ) ;
289
294
}
290
- if ( schema . isPrimitiveType ( type ) ) {
291
- return specPrimitiveToCodePrimitive ( type ) ;
295
+ if ( ! complexType ) {
296
+ return specPrimitiveToCodePrimitive ( type as schema . PrimitiveType ) ;
292
297
} else if ( type === 'Tag' ) {
293
298
// Tags are not considered primitive by the CloudFormation spec (even though they are intrinsic)
294
299
// so we won't consider them primitive either.
@@ -301,9 +306,12 @@ function specTypeToCodeType(resourceContext: CodeName, type: string): CodeName {
301
306
302
307
/**
303
308
* Translate a list of type references in a resource context to a list of code names
309
+ *
310
+ * @param resourceContext
311
+ * @param types name and whether the type is a complex type (true) or primitive type (false)
304
312
*/
305
- export function specTypesToCodeTypes ( resourceContext : CodeName , types : string [ ] ) : CodeName [ ] {
306
- return types . map ( type => specTypeToCodeType ( resourceContext , type ) ) ;
313
+ export function specTypesToCodeTypes ( resourceContext : CodeName , types : { [ name : string ] : boolean } ) : CodeName [ ] {
314
+ return Object . entries ( types ) . map ( ( [ name , complexType ] ) => specTypeToCodeType ( resourceContext , name , complexType ) ) ;
307
315
}
308
316
309
317
export interface PropertyVisitor < T > {
0 commit comments