( ts: TypeScript, node: typescript.BinaryExpression )
| 251 | } |
| 252 | |
| 253 | function evaluateStringConcat( |
| 254 | ts: TypeScript, |
| 255 | node: typescript.BinaryExpression |
| 256 | ): [result: string, isStaticallyEvaluatable: boolean] { |
| 257 | const right = unwrapTransparentTypeScriptExpression(ts, node.right) |
| 258 | const left = unwrapTransparentTypeScriptExpression(ts, node.left) |
| 259 | if (!ts.isStringLiteral(right)) { |
| 260 | return ['', false] |
| 261 | } |
| 262 | if (ts.isStringLiteral(left)) { |
| 263 | return [left.text + right.text, true] |
| 264 | } |
| 265 | if (ts.isBinaryExpression(left)) { |
| 266 | const [result, isStatic] = evaluateStringConcat(ts, left) |
| 267 | return [result + right.text, isStatic] |
| 268 | } |
| 269 | return ['', false] |
| 270 | } |
| 271 | |
| 272 | function unwrapTransparentTypeScriptExpression( |
| 273 | ts: TypeScript, |
no test coverage detected