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)); comments.push(/** @type {AST.JSComment} */ (comment));
} }
// a module read on its own is one piece: its program, in its own scope // 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, { keep_tables(answer.node, {
node: answer.node, node: answer.node,
scope: answer.scopes[0], scope: scopes[0],
scopes: answer.scopes.slice(1), scopes: scopes.slice(1),
bindings: answer.bindings, bindings: /** @type {teasel.Binding[]} */ (answer.bindings),
references: answer.references references: /** @type {teasel.Reference[]} */ (answer.references)
}); });
return answer.node; return answer.node;

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

Loading…
Cancel
Save