You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
941 B

4 years ago
  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. }