feat(type-parsing): use oxc-parser#887
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #887 +/- ##
==========================================
+ Coverage 85.19% 85.28% +0.09%
==========================================
Files 180 186 +6
Lines 16570 16837 +267
Branches 1514 1496 -18
==========================================
+ Hits 14116 14359 +243
- Misses 2444 2470 +26
+ Partials 10 8 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| current.textRaw = transformNodesToString( | ||
| child.children.filter(node => node !== subList) | ||
| ) | ||
| .replace(/\s+/g, ' ') | ||
| .replace(/<!--.*?-->/gs, ''); |
| // Shiki tokenizes `vm`, `.`, `Module` separately; the whole range links | ||
| const anchors = html.match(/href="vm.html#class-module"/g); | ||
| assert.ok(anchors.length >= 1); | ||
| assert.match(html.replace(/<[^>]+>/g, ''), /^vm\.Module$/); |
There was a problem hiding this comment.
we don't care we are on test and this code will took more computing time so we didn't have any interest of doing that
PR SummaryMedium Risk Overview Resolution and output now follow spec §8: optional whole-value type-map match, then per-identifier links (type map → builtins → MDN → dotted-name heuristic); parse failures warn and render as plain code. Rendering is a single inline Downstream generators (metadata, legacy-json, jsx-ast, man-page, legacy-html) consume Reviewed by Cursor Bugbot for commit 52e418d. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
The diff was too big to leave as a comment |
There was a problem hiding this comment.
This changes the version of the spec right? How have we been handling this?
There was a problem hiding this comment.
This would be the first change to the spec, however, it's more of a change in wording that behavior. The only behavioral change is that {string}|{boolean} must now be {string|boolean}. Previously, the spec didn't explicitly say whether to do this or not to do this, now it explicitly says to keep all types with the {...} brackets.
There was a problem hiding this comment.
1.0.0 -> 1.1.0 sounds good?
There was a problem hiding this comment.
i am less concerned if we think its still valid 1.0.0 due to omission - but we should develop some governance over what constitutes a change. imagine semver would work in moooooooost cases
|
@bmuenzenmeyer i ended up patching instead of minoring since we previously claim to support these types and similar ones, and this is more of an improvement on that claim than a new feature of the spec. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 046386f. Configure here.
|
Bump @nodejs/web-infra |
|
do you know what the impact in terms:
Is it possible to achieve this with other parser such as oxc/swc which is lighter that full typescript package somethign like that: import { parseSync, Visitor } from "oxc-parser";
function parseTypeValues(values: string[]) {
// Same trick as today: wrap each type in a synthetic alias.
const source = values
.map((value, i) => `type $T${i} = ${value};`)
.join("\n");
const result = parseSync("types.ts", source);
if (result.errors.length > 0) {
// Same fallback strategy as today:
// parse each type individually to isolate invalid annotations.
return fallback(values);
}
const identifiersPerAlias = values.map(() => []);
const visitor = new Visitor({
TSTypeReference(node) {
// Promise<T> / vm.Module / Foo.Bar
record(node.typeName);
},
TSTypeQuery(node) {
// typeof Foo
record(node.exprName);
},
TSImportType(node) {
// import("fs").Stats
record(node.qualifier);
},
TSThisType(node) {
record(node);
},
TSLiteralType(node) {
// null
if (node.literal.type === "NullLiteral") {
record(node);
}
},
TSStringKeyword: record,
TSNumberKeyword: record,
TSBooleanKeyword: record,
TSAnyKeyword: record,
TSUnknownKeyword: record,
TSNeverKeyword: record,
TSVoidKeyword: record,
TSUndefinedKeyword: record,
TSObjectKeyword: record,
TSBigIntKeyword: record,
TSSymbolKeyword: record,
});
visitor.visit(result.program);
return identifiersPerAlias;
function record(node) {
// node.range / node.span provides source offsets
// determine which synthetic alias this belongs to
// convert to offsets relative to the original annotation
// push { start, end, text, lookup }
}
} |
oxc-parser
|
@AugustinMauroy nice suggestion! Moved to oxc |

Uh oh!
There was an error while loading. Please reload this page.