helpers.js 941 B

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.hasMinVersion = hasMinVersion;
  6. exports.typeAnnotationToString = typeAnnotationToString;
  7. var _semver = _interopRequireDefault(require("semver"));
  8. var _core = require("@babel/core");
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. function hasMinVersion(minVersion, runtimeVersion) {
  11. if (!runtimeVersion) return true;
  12. if (_semver.default.valid(runtimeVersion)) runtimeVersion = `^${runtimeVersion}`;
  13. return !_semver.default.intersects(`<${minVersion}`, runtimeVersion) && !_semver.default.intersects(`>=8.0.0`, runtimeVersion);
  14. }
  15. function typeAnnotationToString(node) {
  16. switch (node.type) {
  17. case "GenericTypeAnnotation":
  18. if (_core.types.isIdentifier(node.id, {
  19. name: "Array"
  20. })) return "array";
  21. break;
  22. case "StringTypeAnnotation":
  23. return "string";
  24. }
  25. }