util.js 916 B

12345678910111213141516171819
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.resolveTemplateTSOptions = void 0;
  4. function resolveTemplateTSOptions(descriptor, options) {
  5. var _a, _b, _c;
  6. if (options.enableTsInTemplate === false)
  7. return null;
  8. const lang = ((_a = descriptor.script) === null || _a === void 0 ? void 0 : _a.lang) || ((_b = descriptor.scriptSetup) === null || _b === void 0 ? void 0 : _b.lang);
  9. const isTS = !!(lang && /tsx?$/.test(lang));
  10. let expressionPlugins = ((_c = options === null || options === void 0 ? void 0 : options.compilerOptions) === null || _c === void 0 ? void 0 : _c.expressionPlugins) || [];
  11. if (isTS && !expressionPlugins.includes('typescript')) {
  12. expressionPlugins = [...expressionPlugins, 'typescript'];
  13. }
  14. return {
  15. isTS,
  16. expressionPlugins,
  17. };
  18. }
  19. exports.resolveTemplateTSOptions = resolveTemplateTSOptions;