fix(code-gen): fix types error

This commit is contained in:
LeoYuan 袁力皓 2023-06-05 16:10:35 +08:00 committed by eternalsky
parent 03495ba9ef
commit 622806f59c

View File

@ -167,7 +167,7 @@ export function parseExpressionGetKeywords(expr: string | null | undefined): str
],
});
const addIdentifierIfNeeded = (x: Record<string, unknown> | number | null | undefined) => {
const addIdentifierIfNeeded = (x: Node | null | undefined) => {
if (typeof x === 'object' && isIdentifier(x) && JS_KEYWORDS.includes(x.name)) {
keywordVars.add(x.name);
}
@ -189,7 +189,7 @@ export function parseExpressionGetKeywords(expr: string | null | undefined): str
addIdentifierIfNeeded(item);
});
} else {
addIdentifierIfNeeded(fieldValue as Record<string, unknown> | null);
addIdentifierIfNeeded(fieldValue as any);
}
}
});
@ -217,7 +217,7 @@ export function parseExpressionGetGlobalVariables(
const ast = parser.parse(`!(${expr});`);
const addUndeclaredIdentifierIfNeeded = (
x: Record<string, unknown> | number | null | undefined,
x: Node | null | undefined,
path: NodePath<Node>,
) => {
if (typeof x === 'object' && isIdentifier(x) && !path.scope.hasBinding(x.name)) {
@ -241,7 +241,7 @@ export function parseExpressionGetGlobalVariables(
addUndeclaredIdentifierIfNeeded(item, path);
});
} else {
addUndeclaredIdentifierIfNeeded(fieldValue as Record<string, unknown> | null, path);
addUndeclaredIdentifierIfNeeded(fieldValue as any, path);
}
}
});