UNPKG

astx

Version:

super powerful structural search and replace for JavaScript and TypeScript to automate your refactoring

35 lines (28 loc) 1.16 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = compileTSTypeReferenceMatcher; var _Placeholder = _interopRequireDefault(require("./Placeholder")); var _SpecialMatcher = _interopRequireDefault(require("./SpecialMatcher")); function compileTSTypeReferenceMatcher(path, compileOptions) { var _path$value = path.value, typeName = _path$value.typeName, typeParameters = _path$value.typeParameters; var n = compileOptions.backend.t.namedTypes; if (n.Identifier.check(typeName)) { if (typeParameters == null) { var placeholderMatcher = (0, _Placeholder["default"])(path, typeName.name, compileOptions, { nodeType: 'TSType' }); if (placeholderMatcher) return placeholderMatcher; } else { var typeParametersPath = path.get('typeParameters'); if (typeParametersPath.value) { var special = (0, _SpecialMatcher["default"])(path, typeName.name, typeParametersPath.get('params'), compileOptions); if (special) return special; } } } }