MCPcopy Create free account
hub / github.com/glideapps/quicktype / matchType

Function matchType

src/Type.ts:491–529  ·  view source on GitHub ↗
(
    t: Type,
    anyType: (anyType: PrimitiveType) => U,
    nullType: (nullType: PrimitiveType) => U,
    boolType: (boolType: PrimitiveType) => U,
    integerType: (integerType: PrimitiveType) => U,
    doubleType: (doubleType: PrimitiveType) => U,
    stringType: (stringType: PrimitiveType) => U,
    arrayType: (arrayType: ArrayType) => U,
    classType: (classType: ClassType) => U,
    mapType: (mapType: MapType) => U,
    enumType: (enumType: EnumType) => U,
    unionType: (unionType: UnionType) => U,
    stringTypeMatchers?: StringTypeMatchers<U>
)

Source from the content-addressed store, hash-verified

489}
490
491export function matchType<U>(
492 t: Type,
493 anyType: (anyType: PrimitiveType) => U,
494 nullType: (nullType: PrimitiveType) => U,
495 boolType: (boolType: PrimitiveType) => U,
496 integerType: (integerType: PrimitiveType) => U,
497 doubleType: (doubleType: PrimitiveType) => U,
498 stringType: (stringType: PrimitiveType) => U,
499 arrayType: (arrayType: ArrayType) => U,
500 classType: (classType: ClassType) => U,
501 mapType: (mapType: MapType) => U,
502 enumType: (enumType: EnumType) => U,
503 unionType: (unionType: UnionType) => U,
504 stringTypeMatchers?: StringTypeMatchers<U>
505): U {
506 if (stringTypeMatchers === undefined) {
507 stringTypeMatchers = {};
508 }
509 const typeNotSupported = (_: Type) => {
510 return panic("Unsupported PrimitiveType");
511 };
512 return matchTypeExhaustive(
513 t,
514 anyType,
515 nullType,
516 boolType,
517 integerType,
518 doubleType,
519 stringType,
520 arrayType,
521 classType,
522 mapType,
523 enumType,
524 unionType,
525 stringTypeMatchers.dateType || typeNotSupported,
526 stringTypeMatchers.timeType || typeNotSupported,
527 stringTypeMatchers.dateTimeType || typeNotSupported
528 );
529}
530
531export function matchCompoundType(
532 t: Type,

Callers 8

GoRendererClass · 0.90
ElmRendererClass · 0.90
JavaRendererClass · 0.90
TypeScriptRendererClass · 0.90
SwiftRendererClass · 0.90
CSharpRendererClass · 0.90
CPlusPlusRendererClass · 0.90
matchCompoundTypeFunction · 0.85

Calls 1

matchTypeExhaustiveFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…