Skip to content

Conversation

@xandris
Copy link

@xandris xandris commented Nov 13, 2025

Hello, this is the first Rust I've ever read/written. I'd like to fix #636. The guards against mangling type parameter lists were in place but deactivated by trailingCommas: never. Change it to always check before applying the preferred style.

I noticed it checked for function<T> as well, but in my testing neither function expressions nor declarations are ambiguous:

// These parse correctly even in TSX
function foo<T>() { }
const foo = function<T>() {}
class foo<T>() { }
const foo = class<T>() {}

The presence of the function or class keywords seems to be enough for the TypeScript parser to disambiguate.

Thank you, dprint and its plugins are such a delight.

Neither function expressions nor function declarations are ambiguous:

```typescript
// These parse correctly even in TSX
function foo<T>() { }
const foo = function<T>() {}
```

Only arrow functions are ambiguous. The presence of the `function` or `class` keywords is enough for the TypeScript parser to disambiguate.

The guards against this were in place but deactivated by `trailingCommas: never`. Change it to always check before applying the preferred style.

See: dprint#636
Signed-off-by: Alexandra Parker <[email protected]>
@xandris xandris changed the title fix(jsx): avoid making type param lists ambiguous fix(jsx): avoid making type param lists ambiguous when trailingCommas is never Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't trailing generic comma when format tsx file when trailingComma: never

1 participant