Skip to content

Prettier (in StackBlitz) removes trailing comma in generic arguments in tsx files #9

Open
@kimroen

Description

@kimroen

As an example, in this challenge: src/05-generics/39-generic-props.problem.tsx.

This happens in all challenges involving a single unconstrained type argument in a TSX file (which admittedly doesn't happen extremely often).

We need to add a comma after the T, like this:

-export const Table = (props: TableProps) => {
+export const Table = <T,>(props: TableProps<T>) => {

However, when saving the file in StackBlitz Prettier removes the ,, making the file invalid:

-export const Table = <T,>(props: TableProps<T>) => {
+export const Table = <T>(props: TableProps<T>) => {

Luckily, the optional way of doing this with T extends unknown works here:

-export const Table = <T,>(props: TableProps<T>) => {
+export const Table = <T extends unknown>(props: TableProps<T>) => {

This should have been fixed in Prettier in 2019 though, so I'm not sure why this would be happening here: prettier/prettier#6114

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions