File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
packages/hypergraph-react/src/internal Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,11 @@ export const parseResult = <S extends Schema.Schema.AnyNoContext>(queryData: Ent
185185 const ast = type . ast as SchemaAST . TypeLiteral ;
186186
187187 for ( const prop of ast . propertySignatures ) {
188- const propType = prop . isOptional ? prop . type . types [ 0 ] : prop . type ;
188+ const propType =
189+ prop . isOptional && SchemaAST . isUnion ( prop . type )
190+ ? ( prop . type . types . find ( ( member ) => ! SchemaAST . isUndefinedKeyword ( member ) ) ?? prop . type )
191+ : prop . type ;
192+
189193 const result = SchemaAST . getAnnotation < string > ( Constants . PropertyIdSymbol ) ( propType ) ;
190194
191195 if ( Option . isSome ( result ) ) {
Original file line number Diff line number Diff line change @@ -200,7 +200,11 @@ export const parseResult = <S extends Schema.Schema.AnyNoContext>(queryData: Ent
200200 const ast = type . ast as SchemaAST . TypeLiteral ;
201201
202202 for ( const prop of ast . propertySignatures ) {
203- const propType = prop . isOptional ? prop . type . types [ 0 ] : prop . type ;
203+ const propType =
204+ prop . isOptional && SchemaAST . isUnion ( prop . type )
205+ ? ( prop . type . types . find ( ( member ) => ! SchemaAST . isUndefinedKeyword ( member ) ) ?? prop . type )
206+ : prop . type ;
207+
204208 const result = SchemaAST . getAnnotation < string > ( Constants . PropertyIdSymbol ) ( propType ) ;
205209
206210 if ( Option . isSome ( result ) ) {
You can’t perform that action at this time.
0 commit comments