File tree Expand file tree Collapse file tree 1 file changed +13
-12
lines changed
Expand file tree Collapse file tree 1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -66,22 +66,23 @@ function handleTyped(
6666 typeNodes : Node [ ] ,
6767 property ?: Value ,
6868) : DeepPartial < Typed > | undefined {
69- // Support multiple types, merged into array. If only one, keep as object.
70- let type : DeepPartial < Typed > | undefined ;
71- if ( typeNodes . length === 1 ) {
72- type = handleSingleTypeNode ( typeNodes [ 0 ] ) ;
73- } else if ( typeNodes . length > 1 ) {
74- const types = typeNodes . map ( handleSingleTypeNode ) ;
75- type = { type : types } ;
76- } else if ( property ) {
77- type = {
69+ if ( property ) {
70+ if ( typeNodes . length ) {
71+ throw new Error ( "Type nodes can't coexist with type property" ) ;
72+ }
73+ return {
7874 type : string ( property ) ,
7975 subtype : undefined ,
8076 } ;
81- } else {
82- type = undefined ;
8377 }
84- return type ;
78+
79+ const types = typeNodes . map ( handleSingleTypeNode ) ;
80+ if ( typeNodes . length > 1 ) {
81+ // union types
82+ return { type : types } ;
83+ }
84+ // either a non-union type or no type
85+ return types [ 0 ] ;
8586}
8687
8788function handleTypeParameters ( value : Value | Node ) {
You can’t perform that action at this time.
0 commit comments