File tree Expand file tree Collapse file tree 2 files changed +27
-12
lines changed Expand file tree Collapse file tree 2 files changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -479,15 +479,25 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
479479 Node . isPropertyDeclaration ( member ) || Node . isPropertySignature ( member ) ,
480480 'Class and interfaces can only have property declarations or signatures'
481481 )
482- const property = modelProperty ( member )
483- if ( type . variants ?. kind === 'container' && property . containerProperty == null ) {
484- assert (
485- member ,
486- ! property . required ,
487- 'All @variants container properties must be optional'
488- )
482+ try {
483+ const property = modelProperty ( member )
484+ if ( type . variants ?. kind === 'container' && property . containerProperty == null ) {
485+ assert (
486+ member ,
487+ ! property . required ,
488+ 'All @variants container properties must be optional'
489+ )
490+ }
491+ type . properties . push ( property )
492+ } catch ( e ) {
493+ const name = declaration . getName ( )
494+ if ( name !== undefined ) {
495+ console . log ( `failed to parse ${ name } , reason:` , e . message )
496+ } else {
497+ console . log ( 'failed to parse field, reason:' , e . message )
498+ }
499+ process . exit ( 1 )
489500 }
490- type . properties . push ( property )
491501 }
492502
493503 // The class or interface is extended, an extended class or interface could
Original file line number Diff line number Diff line change @@ -532,10 +532,15 @@ export function modelProperty (declaration: PropertySignature | PropertyDeclarat
532532
533533 // names that contains `.` or `-` will be wrapped inside single quotes
534534 const name = declaration . getName ( ) . replace ( / ' / g, '' )
535- const property = {
536- name,
537- required : ! declaration . hasQuestionToken ( ) ,
538- type : modelType ( type )
535+ let property : model . Property
536+ try {
537+ property = {
538+ name,
539+ required : ! declaration . hasQuestionToken ( ) ,
540+ type : modelType ( type )
541+ }
542+ } catch ( e ) {
543+ throw new Error ( `cannot determine type of ${ name } , got:${ type . getFullText ( ) } ` )
539544 }
540545 hoistPropertyAnnotations ( property , declaration . getJsDocs ( ) )
541546 return property
You can’t perform that action at this time.
0 commit comments