MCPcopy Create free account
hub / github.com/LambdaNote/support-ts-tapl / getProp

Function getProp

article/utils.ts:195–203  ·  view source on GitHub ↗
(property: p.TSESTree.ObjectLiteralElement)

Source from the content-addressed store, hash-verified

193}
194
195function getProp(property: p.TSESTree.ObjectLiteralElement) {
196 if (property.type === "SpreadElement") error("spread operator is not allowed", property);
197 if (property.computed) error("key must be bare", property);
198 if (property.value.type === "AssignmentPattern") error("AssignmentPattern is not allowed", property);
199 if (property.value.type === "TSEmptyBodyFunctionExpression") {
200 error("TSEmptyBodyFunctionExpression is not allowed", property);
201 }
202 return { key: getIdentifier(property.key), value: property.value };
203}
204
205function getTagAndVal(node: p.TSESTree.ObjectExpression) {
206 if (node.properties.length !== 2) error(`tagged union must be <TYPE>{ tag: "TAG", val: EXPR }`, node);

Callers 2

getTagAndValFunction · 0.70
convertExprFunction · 0.70

Calls 2

errorFunction · 0.70
getIdentifierFunction · 0.70

Tested by

no test coverage detected