feat: add missing AST nodes to FunctionlessAST for 1:1 parity with TS#347
feat: add missing AST nodes to FunctionlessAST for 1:1 parity with TS#347sam-goodwin merged 30 commits intomainfrom
Conversation
✅ Deploy Preview for effortless-malabi-1c3e77 ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Signed-off-by: github-actions <github-actions@github.com>
| for (const arg of args) { | ||
| setParent(arg); | ||
| } |
There was a problem hiding this comment.
nit: setParent(arg) (if IArguments is an array, it will just recurse)
There was a problem hiding this comment.
I don't understand, what's wrong?
There was a problem hiding this comment.
Nothing wrong, just saying your function also supports arrays of arguments so it could be written as:
const setParent = (node: any) => {
if (!node) {
return;
} else if (isNode(node)) {
node.setParent(this as FunctionlessNode);
} else if (Array.isArray(node)) {
node.forEach(setParent);
}
};
setParent(args);There was a problem hiding this comment.
Actually, IArguments is not an array, it is only Iterable
There was a problem hiding this comment.
Let me take another look, perhaps I got confused by a type error. I do remember doing it your way to begin with
| for (const arg of args) { | ||
| setParent(arg); | ||
| } |
There was a problem hiding this comment.
Nothing wrong, just saying your function also supports arrays of arguments so it could be written as:
const setParent = (node: any) => {
if (!node) {
return;
} else if (isNode(node)) {
node.setParent(this as FunctionlessNode);
} else if (Array.isArray(node)) {
node.forEach(setParent);
}
};
setParent(args);
This change will bring 1:1 parity of the FunctionlessAST with the TypeScript AST so that our annotation process can support all valid syntax. Interpreters can still ignore unsupported statements, but we should be able to totally represent programs with our AST.
BREAKING CHANGE: FunctionlessAST contract changed to be 1:1 with ES AST.