@@ -39,20 +39,24 @@ check(
3939) ;
4040
4141const composition = registrySource . match (
42- / e x p o r t c o n s t P r o t o c o l S c h e m a s : ( [ \s \S ] * ?) = c o m p o s e P r o t o c o l S c h e m a F r a g m e n t s \( \[ ( [ \s \S ] * ?) \] \s + a s c o n s t \) ; / u,
42+ / e x p o r t c o n s t P r o t o c o l S c h e m a s : \s * ( [ \s \S ] * ?) \s * = c o m p o s e P r o t o c o l S c h e m a F r a g m e n t s \( \[ ( [ \s \S ] * ?) \] \s + a s c o n s t \) ; / u,
4343) ;
44- const declaredBindings = ( composition ?. [ 1 ] ?? "" )
45- . split ( "&" )
46- . map ( ( type ) => type . trim ( ) . replace ( / ^ t y p e o f \s + / u, "" ) ) ;
4744const composedBindings = ( composition ?. [ 2 ] ?? "" )
4845 . split ( "\n" )
4946 . map ( ( line ) => line . trim ( ) . replace ( / , $ / u, "" ) )
5047 . filter ( Boolean ) ;
48+ const annotatedBindings = ( composition ?. [ 1 ] ?? "" )
49+ . split ( "&" )
50+ . map ( ( type ) => / ^ t y p e o f ( [ A - Z a - z 0 - 9 _ ] + ) $ / u. exec ( type . trim ( ) ) ?. [ 1 ] ) ;
5151const importedBindings = fragmentImports . map ( ( { binding } ) => binding ) ;
52- check ( Boolean ( composition ) , `${ registryPath } must explicitly compose an ordered fragment array` ) ;
5352check (
54- JSON . stringify ( declaredBindings ) === JSON . stringify ( composedBindings ) ,
55- `${ registryPath } must declare the same named fragment types as its composition` ,
53+ Boolean ( composition ) ,
54+ `${ registryPath } must explicitly type and compose an ordered fragment array` ,
55+ ) ;
56+ check (
57+ annotatedBindings . length === composedBindings . length &&
58+ annotatedBindings . every ( ( binding , index ) => binding === composedBindings [ index ] ) ,
59+ `${ registryPath } must annotate the composed fragments with their exact ordered typeof intersection` ,
5660) ;
5761check (
5862 composedBindings . length === importedBindings . length &&
0 commit comments