UNPKG

@builder.io/mitosis

Version:

Write components once, run everywhere. Compiles to Vue, React, Solid, and Liquid. Import code from Figma and Builder.io

23 lines (22 loc) 903 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findOptionalProps = void 0; const ts_morph_1 = require("ts-morph"); const typescript_project_1 = require("../../helpers/typescript-project"); const findOptionalProps = (args) => { const ast = args.project.getSourceFileOrThrow(args.filePath); if (ast === undefined) { throw new Error('Could not find AST. Please provide either `code` or `filePath` configs.'); } const propsSymbol = (0, typescript_project_1.getPropsSymbol)(ast); if (!propsSymbol) return []; return propsSymbol .getDeclarations()[0] .getType() .getProperties() .map((p) => p.getDeclarations()[0]) .filter((k) => ts_morph_1.PropertySignature.isPropertySignature(k) && k.hasQuestionToken()) .map((k) => k.getName()); }; exports.findOptionalProps = findOptionalProps;