Skip to content

Commit 7322fa8

Browse files
alexander-akaitclaude
authored andcommitted
refactor(javascript): type the nodes the syntax parser builds
Replace EXPECTED_ANY in lib/javascript/syntax-parser.js with node typedefs declared in the parser itself, named and shaped as ESTree's. startNode returns an UnfinishedNode whose fields keep their real types, and finishNode returns the exact node. The typedefs are @internal: the types generator writes them as any, so types.d.ts keeps main's public signatures.
1 parent 57c5e87 commit 7322fa8

7 files changed

Lines changed: 2180 additions & 1214 deletions

File tree

‎lib/javascript/regexp.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,9 +1784,9 @@ const install = (target) => {
17841784
for (const name of Object.getOwnPropertyNames(RegExpValidator.prototype)) {
17851785
if (name === "constructor") continue;
17861786
if (Object.prototype.hasOwnProperty.call(target.prototype, name)) continue;
1787-
/** @type {Record<string, RegExpValidator[keyof RegExpValidator]>} */
1787+
/** @type {Parser & Record<string, RegExpValidator[keyof RegExpValidator]>} */
17881788
(target.prototype)[name] =
1789-
/** @type {Record<string, RegExpValidator[keyof RegExpValidator]>} */ (
1789+
/** @type {RegExpValidator & Record<string, RegExpValidator[keyof RegExpValidator]>} */ (
17901790
RegExpValidator.prototype
17911791
)[name];
17921792
}

0 commit comments

Comments
 (0)