File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,16 @@ const rfc3339 = [
58
58
} ,
59
59
] ;
60
60
61
+ function matchFilter ( matches : RegExpMatchArray | null ) : boolean {
62
+ if ( ! matches ) {
63
+ return false ;
64
+ }
65
+
66
+ const truthyMatches = matches . filter ( ( match ) => ! ! match ) ;
67
+
68
+ return truthyMatches . length > 2 ;
69
+ }
70
+
61
71
function inferRFC3339 ( value : string ) : JSONDateTimeFormat | undefined {
62
72
const rfc3339Matches = rfc3339
63
73
. map ( ( rfc ) => {
@@ -67,7 +77,7 @@ function inferRFC3339(value: string): JSONDateTimeFormat | undefined {
67
77
extensions : rfc . extensions ,
68
78
} ;
69
79
} )
70
- . filter ( ( rfc ) => rfc . matches !== null && rfc . matches . some ( ( i ) => i ) ) ;
80
+ . filter ( ( rfc ) => matchFilter ( rfc . matches ) ) ;
71
81
72
82
const rfc3339BestMatch = rfc3339Matches . sort (
73
83
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Original file line number Diff line number Diff line change @@ -811,3 +811,12 @@ describe("credit cards", () => {
811
811
} ,
812
812
) ;
813
813
} ) ;
814
+
815
+ describe ( "without format" , ( ) => {
816
+ test . each ( [ "46" ] ) ( "%p should be inferred as having no format" , ( value ) => {
817
+ expect ( inferType ( value ) ) . toEqual ( {
818
+ name : "string" ,
819
+ value,
820
+ } ) ;
821
+ } ) ;
822
+ } ) ;
You can’t perform that action at this time.
0 commit comments