( ts: TypeScript, obj: typescript.ObjectLiteralExpression )
| 104 | } |
| 105 | |
| 106 | function objectLiteralExpressionToObj( |
| 107 | ts: TypeScript, |
| 108 | obj: typescript.ObjectLiteralExpression |
| 109 | ): object { |
| 110 | return obj.properties.reduce((all: Record<string, any>, prop) => { |
| 111 | if (ts.isPropertyAssignment(prop) && prop.name) { |
| 112 | if (ts.isIdentifier(prop.name)) { |
| 113 | all[prop.name.escapedText.toString()] = literalToObj( |
| 114 | ts, |
| 115 | prop.initializer |
| 116 | ) |
| 117 | } else if (ts.isStringLiteral(prop.name)) { |
| 118 | all[prop.name.text] = literalToObj(ts, prop.initializer) |
| 119 | } |
| 120 | } |
| 121 | return all |
| 122 | }, {}) |
| 123 | } |
| 124 | |
| 125 | export interface Opts { |
| 126 | /** |
no test coverage detected