the tables a root keeps are typed as a root's; the module's answer is cast where its option is known on

goodbye-acorn
Nic 3 weeks ago
parent 05bba23563
commit 45e48602f6

@ -30,12 +30,13 @@ export function parse(source, comments, typescript) {
comments.push(/** @type {AST.JSComment} */ (comment));
}
// a module read on its own is one piece: its program, in its own scope
const scopes = /** @type {teasel.Scope[]} */ (answer.scopes);
keep_tables(answer.node, {
node: answer.node,
scope: answer.scopes[0],
scopes: answer.scopes.slice(1),
bindings: answer.bindings,
references: answer.references
scope: scopes[0],
scopes: scopes.slice(1),
bindings: /** @type {teasel.Binding[]} */ (answer.bindings),
references: /** @type {teasel.Reference[]} */ (answer.references)
});
return answer.node;

@ -12,13 +12,13 @@ import { bindingOf } from '@teasel/parser';
const PARSED = Symbol('parsed');
/**
* Keeps the parser's answer on the root it parsed, a script's program or a template's
* expression, pattern, parameter list or declaration, for its tables.
* Keeps the parser's tables on the root they belong to, a script's program or a template's
* expression, pattern, parameter list or declaration.
* @param {object} root
* @param {import('@teasel/parser').Parsed<unknown>} answer
* @param {Tables} tables
*/
export function keep_tables(root, answer) {
/** @type {any} */ (root)[PARSED] = answer;
export function keep_tables(root, tables) {
/** @type {any} */ (root)[PARSED] = tables;
}
/**

Loading…
Cancel
Save