@@ -21,7 +21,7 @@ const DEFAULT_TYPEDEFS_HEADER = [
2121 '// DO NOT MODIFY THIS FILE BY HAND.' ,
2222] ;
2323
24- const getPropertyTypeAnnotation = ( property : ComponentPropertySchema ) => {
24+ const getPropertyTypeAnnotation = ( property : ComponentPropertySchema , prefix ?: string ) => {
2525 // If a property type is one of the ones provided by Storyblok, return that type
2626 // Casting as string[] to avoid TS error on using Array.includes on different narrowed types
2727 if ( Array . from ( storyblokSchemas . keys ( ) ) . includes ( property . type as StoryblokPropertyType ) ) {
@@ -42,13 +42,13 @@ const getPropertyTypeAnnotation = (property: ComponentPropertySchema) => {
4242 if ( property . filter_content_type ) {
4343 if ( typeof property . filter_content_type === 'string' ) {
4444 return {
45- tsType : `(${ getStoryType ( property . filter_content_type ) } | string )${ property . type === 'options' ? '[]' : '' } ` ,
45+ tsType : `(${ getStoryType ( property . filter_content_type , prefix ) } | string )${ property . type === 'options' ? '[]' : '' } ` ,
4646 } ;
4747 }
4848
4949 return {
5050 tsType : `(${ property . filter_content_type
51- . map ( type2 => getStoryType ( type2 ) )
51+ . map ( type2 => getStoryType ( type2 , prefix ) )
5252 // In this case property.type can be `option` or `options`. In case of `options` the type should be an array
5353 . join ( ' | ' ) } | string )${ property . type === 'options' ? '[]' : '' } `,
5454 } ;
@@ -115,8 +115,8 @@ const getPropertyTypeAnnotation = (property: ComponentPropertySchema) => {
115115 }
116116} ;
117117
118- export function getStoryType ( property : string ) {
119- return `${ STORY_TYPE } <${ capitalize ( property ) } >` ;
118+ export function getStoryType ( property : string , prefix ?: string ) {
119+ return `${ STORY_TYPE } <${ prefix ?? '' } ${ capitalize ( toCamelCase ( property ) ) } >` ;
120120}
121121
122122/**
@@ -167,7 +167,7 @@ const getComponentPropertiesTypeAnnotations = async (
167167
168168 const propertyType = value . type ;
169169 const propertyTypeAnnotation : JSONSchema = {
170- [ key ] : getPropertyTypeAnnotation ( value as ComponentPropertySchema ) ,
170+ [ key ] : getPropertyTypeAnnotation ( value as ComponentPropertySchema , options . typePrefix ) ,
171171 } ;
172172
173173 if ( propertyType === 'custom' && customFieldsParser ) {
0 commit comments