add babel types
This commit is contained in:
parent
7bf64b6586
commit
b1e20bfd3f
|
|
@ -1,6 +1,7 @@
|
||||||
import { css } from './common/tags.ts';
|
import { css } from './common/tags.ts';
|
||||||
import { FolkRope } from './folk-rope.ts';
|
import { FolkRope } from './folk-rope.ts';
|
||||||
import * as parser from '@babel/parser';
|
import * as parser from '@babel/parser';
|
||||||
|
import type { Node } from '@babel/types';
|
||||||
|
|
||||||
const styles = new CSSStyleSheet();
|
const styles = new CSSStyleSheet();
|
||||||
styles.replaceSync(css`
|
styles.replaceSync(css`
|
||||||
|
|
@ -220,7 +221,7 @@ function parseAst(functionBody: string) {
|
||||||
const toProps = new Set<string>();
|
const toProps = new Set<string>();
|
||||||
const fromProps = new Set<string>();
|
const fromProps = new Set<string>();
|
||||||
|
|
||||||
function walkAst(node: any) {
|
function walkAst(node: Node) {
|
||||||
if (!node || typeof node !== 'object') return;
|
if (!node || typeof node !== 'object') return;
|
||||||
|
|
||||||
if (node.type === 'MemberExpression' && node.object?.type === 'Identifier') {
|
if (node.type === 'MemberExpression' && node.object?.type === 'Identifier') {
|
||||||
|
|
@ -237,11 +238,12 @@ function parseAst(functionBody: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recursively walk through all properties
|
// Recursively walk through all properties
|
||||||
for (const key in node) {
|
for (const key of Object.keys(node)) {
|
||||||
if (Array.isArray(node[key])) {
|
const value = (node as any)[key];
|
||||||
node[key].forEach(walkAst);
|
if (Array.isArray(value)) {
|
||||||
} else if (node[key] && typeof node[key] === 'object') {
|
value.forEach(walkAst);
|
||||||
walkAst(node[key]);
|
} else if (value && typeof value === 'object') {
|
||||||
|
walkAst(value as Node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue