[Bug]: Print a type parameter's name as the Identifier the next @tsrx/core gives
[!WARNING] Don't start until the
@tsrx/corerelease that includes tsrx-org/tsrx#874 is published (0.5.0, with the changes in #1525 and #1526). Upgrade for all of them together.
Issue Category
Other (preparing for the next @tsrx/core)
Bug Description
The next @tsrx/core gives a type parameter's name as an Identifier with its position, as TypeScript's and Babel 8's trees do, instead of acorn-typescript's string (tsrx-org/tsrx#874, tsrx-org/tsrx#873):
function f<const T extends string>(x: T) {}
type M = { [K in keyof X]: X[K] };TSTypeParameter.name for T, K |
|
|---|---|
@tsrx/core 0.3 / 0.4 |
the string "T", "K" |
@tsrx/core 0.5.0 |
{ type: 'Identifier', name: 'T', start, end, loc } |
This covers <T …>, a mapped type's key (TSMappedType.typeParameter) and infer U.
What Ripple needs to do
The TS view's printers write the name as a string, so with the new tree they would write [object Object]:
TSTypeParameter(context.write(node.name)). It also maps the name to the parameter's start, and leaves outconst/in/out.TSMappedType(context.write(tp.name)).
Replace context.write(…name) with context.visit(…name), which maps the name exactly. Or drop both overrides and let esrap print them: its TypeScript printer already handles the Identifier (esrap languages/ts, TSTypeParameter and TSMappedType), modifiers included.
Nothing else in packages/*/src reads the name (checked at 97d090b9).
Reproduction Steps
After upgrading, the TS view of function f<T>(x: T) {} has <[object Object]> without the change.
Environment
- Ripple
mainat97d090b9,@tsrx/core0.3.x
Additional Context
- tsrx-org/tsrx#874: the change. tsrx-org/tsrx#873: the issue.
@tsrx/oxc: tsrx-org/oxc#125. Octane: octanejs/octane#1354.
Checklist
- I've searched for existing issues
Source: Ripple-TS/ripple