File tree 3 files changed +35
-12
lines changed
docs-tools/src/argTypes/convert
3 files changed +35
-12
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,22 @@ describe('UnknownFlowArgTypesError', () => {
8
8
raw : "SomeType['someProperty']" ,
9
9
} ;
10
10
11
- const message = `"There was a failure when generating ArgTypes in Typescript for {"name":"signature","raw":"SomeType['someProperty']"}
12
- This type is either not supported or it is a bug in Storybook.
13
- If you think this is a bug, please open an issue in Github."` ;
14
-
15
11
const typeError = new UnknownArgTypesError ( { type, language : 'Typescript' } ) ;
16
- expect ( typeError . message ) . toMatchInlineSnapshot ( message ) ;
12
+ expect ( typeError . message ) . toMatchInlineSnapshot ( `
13
+ "There was a failure when generating detailed ArgTypes in Typescript for:
14
+
15
+ {
16
+ "name": "signature",
17
+ "raw": "SomeType['someProperty']"
18
+ }
19
+
20
+ Storybook will fall back to use a generic type description instead.
21
+
22
+ This type is either not supported or it is a bug in the docgen generation in Storybook.
23
+ If you think this is a bug, please detail it as much as possible in the Github issue.
24
+
25
+ More info: https://github.com/storybookjs/storybook/issues/26606
26
+ "
27
+ ` ) ;
17
28
} ) ;
18
29
} ) ;
Original file line number Diff line number Diff line change @@ -259,15 +259,22 @@ export class UnknownArgTypesError extends StorybookError {
259
259
260
260
readonly code = 1 ;
261
261
262
+ readonly documentation = 'https://github.com/storybookjs/storybook/issues/26606' ;
263
+
262
264
constructor ( public data : { type : object ; language : string } ) {
263
265
super ( ) ;
264
266
}
265
267
266
268
template ( ) {
267
- return `There was a failure when generating ArgTypes in ${
269
+ return dedent `There was a failure when generating detailed ArgTypes in ${
268
270
this . data . language
269
- } for ${ JSON . stringify ( this . data . type ) }
270
- This type is either not supported or it is a bug in Storybook.
271
- If you think this is a bug, please open an issue in Github.` ;
271
+ } for:
272
+
273
+ ${ JSON . stringify ( this . data . type , null , 2 ) }
274
+
275
+ Storybook will fall back to use a generic type description instead.
276
+
277
+ This type is either not supported or it is a bug in the docgen generation in Storybook.
278
+ If you think this is a bug, please detail it as much as possible in the Github issue.` ;
272
279
}
273
280
}
Original file line number Diff line number Diff line change @@ -7,9 +7,14 @@ import { convert as propTypesConvert } from './proptypes';
7
7
8
8
export const convert = ( docgenInfo : DocgenInfo ) => {
9
9
const { type, tsType, flowType } = docgenInfo ;
10
- if ( type != null ) return propTypesConvert ( type ) ;
11
- if ( tsType != null ) return tsConvert ( tsType as TSType ) ;
12
- if ( flowType != null ) return flowConvert ( flowType as FlowType ) ;
10
+ try {
11
+ if ( type != null ) return propTypesConvert ( type ) ;
12
+ if ( tsType != null ) return tsConvert ( tsType as TSType ) ;
13
+ if ( flowType != null ) return flowConvert ( flowType as FlowType ) ;
14
+ } catch ( err ) {
15
+ // if we can't convert the type, we'll just return null to fallback to a simple summary, and provide the error to the user
16
+ console . error ( err ) ;
17
+ }
13
18
14
19
return null ;
15
20
} ;
You can’t perform that action at this time.
0 commit comments