Summary
A // comment inside a multi-line type parameter list comments out the rest of the declaration. extractGenerics joins the list onto one line, comments included, so Vue's
export function defineComponent<
// props
TypeProps,
RuntimePropsOptions extends ComponentObjectPropsOptions =
ComponentObjectPropsOptions,
...comes out as export declare function defineComponent<// props TypeProps, ..., with everything after the comment, closing > included, gone. The same happens for type aliases, interfaces and classes. In vue-core (apiDefineComponent, apiCreateApp, componentPublicInstance, apiCustomElement), vue-router (RouteRecordInfo in typed-routes/route-map.ts, four matcher and loader files) and Pinia (types.ts, store.ts) this leaves the generated .d.ts unparsable.
Changes
The collapse now walks the list with skipNonCode, the same scan findMatchingClose used to find its closing >. A // comment is left out, strings, template literals and block comments are copied as they are, and only the whitespace between them is collapsed. Copying literals as they are also stops 'a b' from becoming 'a b', and a multi-line template literal type from losing its newline.
The Zig port joins the list the same way and is not changed here. I can send that as a follow-up.
Testing
New test/generic-parameter-comments.test.ts: a function, a type alias, an interface and a class with comments in their type parameters, plus a list holding '//', 'a b' and a block comment with a URL, and one holding a multi-line template literal. All 6 fail on main: the first four with Bun.Transpiler parse errors such as Thrown value: 1 | export type T<// note A = 1,> = A; and error: Expected identifier but found end of file, the last two with the literal changed ('a b' where 'a b' was written). All pass with the fix.
bun test (Zig library built with the pinned Zig, so its tests run too), typecheck, lint, zig build test and the Zig fixture tests pass. Over 4,192 files from vue-core, vue-router, pinia and knip, with LF and with CRLF line endings, unparsable outputs go from 82 to 71: exactly the 11 files above change, all of them now parse, and the differences are the dropped comments and the text they had swallowed.