mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-02 21:01:51 +00:00
fix(ci): lazy-load TypeScript in ts guard utils
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
import { promises as fs } from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import ts from "typescript";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
let tsCache;
|
||||
|
||||
function getTypeScript() {
|
||||
tsCache ??= require("typescript");
|
||||
return tsCache;
|
||||
}
|
||||
|
||||
const baseTestSuffixes = [".test.ts", ".test-utils.ts", ".test-harness.ts", ".e2e-harness.ts"];
|
||||
|
||||
@@ -113,6 +121,7 @@ export function toLine(sourceFile, node) {
|
||||
}
|
||||
|
||||
export function getPropertyNameText(name) {
|
||||
const ts = getTypeScript();
|
||||
if (ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNumericLiteral(name)) {
|
||||
return name.text;
|
||||
}
|
||||
@@ -120,6 +129,7 @@ export function getPropertyNameText(name) {
|
||||
}
|
||||
|
||||
export function unwrapExpression(expression) {
|
||||
const ts = getTypeScript();
|
||||
let current = expression;
|
||||
while (true) {
|
||||
if (ts.isParenthesizedExpression(current)) {
|
||||
|
||||
Reference in New Issue
Block a user