Skip to content

Commit ec040c4

Browse files
committed
fix(guards): union type string or enum with one value only
1 parent 89da76c commit ec040c4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ function parseInterfaceProperties(
417417
),
418418
)
419419
.join(' && ')})`
420-
: / \| /.test(typescriptType)
420+
: 'enum' in propSchema
421421
? `[${(typescriptType || '').replace(
422422
/ \| /g,
423423
', ',

tests/gcloud-firestore/api/guards/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ export function isValue(arg: any): arg is models.Value {
765765
// mapValue?: MapValue
766766
( typeof arg.mapValue === 'undefined' || isMapValue(arg.mapValue) ) &&
767767
// nullValue?: 'NULL_VALUE'
768-
( typeof arg.nullValue === 'undefined' || is'NULL_VALUE'(arg.nullValue) ) &&
768+
( typeof arg.nullValue === 'undefined' || ['NULL_VALUE'].includes(arg.nullValue) ) &&
769769
// referenceValue?: string
770770
( typeof arg.referenceValue === 'undefined' || typeof arg.referenceValue === 'string' ) &&
771771
// stringValue?: string

0 commit comments

Comments
 (0)