@@ -55,7 +55,7 @@ const allowedVariants = [
55
55
"truthy string" ,
56
56
] as const satisfies VariantType [ ] ;
57
57
58
- const tsHelper = {
58
+ const tsHelpers = {
59
59
isAnyType : ( type : ts . Type ) => isTypeFlagSet ( type , ts . TypeFlags . TypeParameter | ts . TypeFlags . Any ) ,
60
60
isBigIntType : ( type : ts . Type ) => isTypeFlagSet ( type , ts . TypeFlags . BigIntLike ) ,
61
61
isBooleanType : ( type : ts . Type ) => isTypeFlagSet ( type , ts . TypeFlags . BooleanLike ) ,
@@ -102,14 +102,14 @@ const tsHelper = {
102
102
*/
103
103
function inspectVariantTypes ( types : ts . Type [ ] ) {
104
104
const variantTypes = new Set < VariantType > ( ) ;
105
- if ( types . some ( tsHelper . isUnknownType ) ) {
105
+ if ( types . some ( tsHelpers . isUnknownType ) ) {
106
106
variantTypes . add ( "unknown" ) ;
107
107
return variantTypes ;
108
108
}
109
- if ( types . some ( tsHelper . isNullishType ) ) {
109
+ if ( types . some ( tsHelpers . isNullishType ) ) {
110
110
variantTypes . add ( "nullish" ) ;
111
111
}
112
- const booleans = types . filter ( tsHelper . isBooleanType ) ;
112
+ const booleans = types . filter ( tsHelpers . isBooleanType ) ;
113
113
// If incoming type is either "true" or "false", there will be one type
114
114
// object with intrinsicName set accordingly
115
115
// If incoming type is boolean, there will be two type objects with
@@ -134,40 +134,40 @@ function inspectVariantTypes(types: ts.Type[]) {
134
134
break ;
135
135
}
136
136
}
137
- const strings = types . filter ( tsHelper . isStringType ) ;
137
+ const strings = types . filter ( tsHelpers . isStringType ) ;
138
138
if ( strings . length > 0 ) {
139
139
const evaluated = match < ts . Type [ ] , VariantType > ( strings )
140
- . when ( types => types . every ( tsHelper . isTruthyStringType ) , F . constant ( "truthy string" ) )
141
- . when ( types => types . every ( tsHelper . isFalsyStringType ) , F . constant ( "falsy string" ) )
140
+ . when ( types => types . every ( tsHelpers . isTruthyStringType ) , F . constant ( "truthy string" ) )
141
+ . when ( types => types . every ( tsHelpers . isFalsyStringType ) , F . constant ( "falsy string" ) )
142
142
. otherwise ( F . constant ( "string" ) ) ;
143
143
variantTypes . add ( evaluated ) ;
144
144
}
145
- const bigints = types . filter ( tsHelper . isBigIntType ) ;
145
+ const bigints = types . filter ( tsHelpers . isBigIntType ) ;
146
146
if ( bigints . length > 0 ) {
147
147
const evaluated = match < ts . Type [ ] , VariantType > ( bigints )
148
- . when ( types => types . every ( tsHelper . isTruthyBigIntType ) , F . constant ( "truthy bigint" ) )
149
- . when ( types => types . every ( tsHelper . isFalsyBigIntType ) , F . constant ( "falsy bigint" ) )
148
+ . when ( types => types . every ( tsHelpers . isTruthyBigIntType ) , F . constant ( "truthy bigint" ) )
149
+ . when ( types => types . every ( tsHelpers . isFalsyBigIntType ) , F . constant ( "falsy bigint" ) )
150
150
. otherwise ( F . constant ( "bigint" ) ) ;
151
151
variantTypes . add ( evaluated ) ;
152
152
}
153
- const numbers = types . filter ( tsHelper . isNumberType ) ;
153
+ const numbers = types . filter ( tsHelpers . isNumberType ) ;
154
154
if ( numbers . length > 0 ) {
155
155
const evaluated = match < ts . Type [ ] , VariantType > ( numbers )
156
- . when ( types => types . every ( tsHelper . isTruthyNumberType ) , F . constant ( "truthy number" ) )
157
- . when ( types => types . every ( tsHelper . isFalsyNumberType ) , F . constant ( "falsy number" ) )
156
+ . when ( types => types . every ( tsHelpers . isTruthyNumberType ) , F . constant ( "truthy number" ) )
157
+ . when ( types => types . every ( tsHelpers . isFalsyNumberType ) , F . constant ( "falsy number" ) )
158
158
. otherwise ( F . constant ( "number" ) ) ;
159
159
variantTypes . add ( evaluated ) ;
160
160
}
161
- if ( types . some ( tsHelper . isEnumType ) ) {
161
+ if ( types . some ( tsHelpers . isEnumType ) ) {
162
162
variantTypes . add ( "enum" ) ;
163
163
}
164
- if ( types . some ( tsHelper . isObjectType ) ) {
164
+ if ( types . some ( tsHelpers . isObjectType ) ) {
165
165
variantTypes . add ( "object" ) ;
166
166
}
167
- if ( types . some ( tsHelper . isAnyType ) ) {
167
+ if ( types . some ( tsHelpers . isAnyType ) ) {
168
168
variantTypes . add ( "any" ) ;
169
169
}
170
- if ( types . some ( tsHelper . isNeverType ) ) {
170
+ if ( types . some ( tsHelpers . isNeverType ) ) {
171
171
variantTypes . add ( "never" ) ;
172
172
}
173
173
return variantTypes ;
0 commit comments