UNPKG

jsii

Version:

[![Join the chat at https://cdk.Dev](https://img.shields.io/static/v1?label=Slack&message=cdk.dev&color=brightgreen&logo=slack)](https://cdk.dev) [![All Contributors](https://img.shields.io/github/all-contributors/aws/jsii/main?label=%E2%9C%A8%20All%20Con

51 lines 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.visitTypeReference = visitTypeReference; exports.visitType = visitType; exports.isDataType = isDataType; exports.isBehavioralInterfaceType = isBehavioralInterfaceType; const spec = require("@jsii/spec"); function visitTypeReference(typeRef, visitor) { if (spec.isNamedTypeReference(typeRef)) { return visitor.named(typeRef); } else if (spec.isPrimitiveTypeReference(typeRef)) { return visitor.primitive(typeRef); } else if (spec.isCollectionTypeReference(typeRef)) { return visitor.collection(typeRef); } else if (spec.isUnionTypeReference(typeRef)) { return visitor.union(typeRef); } else if (spec.isIntersectionTypeReference(typeRef)) { return visitor.intersection(typeRef); } else { throw new Error(`Unknown type reference: ${JSON.stringify(typeRef)}`); } } function visitType(t, visitor) { if (spec.isClassType(t)) { return visitor.classType(t); } else if (spec.isInterfaceType(t) && t.datatype) { return visitor.dataType(t); } else if (spec.isInterfaceType(t)) { return visitor.interfaceType(t); } else if (spec.isEnumType(t)) { return visitor.enumType(t); } else { throw new Error(`Unknown type: ${JSON.stringify(t)}`); } } function isDataType(t) { return spec.isInterfaceType(t) && !!t.datatype; } function isBehavioralInterfaceType(t) { return spec.isInterfaceType(t) && !t.datatype; } //# sourceMappingURL=type-visitor.js.map