coderaiser / putout

🐊 Pluggable and configurable JavaScript Linter, code transformer and formatter, drop-in ESLint superpower replacement 💪 with built-in support for js, jsx, typescript, flow, markdown, yaml and json. Write declarative codemods in a simplest possible way 😏
https://putout.cloudcmd.io/
MIT License
698 stars 40 forks source link

@putout/printer: Removed useful comma in TS #207

Closed coderaiser closed 3 months ago

coderaiser commented 3 months ago

Started in #206 1 - how it is with ts error 2 - how it should be (was before)

Case 1

const MultiChips = <T>({items, idProperty, labelProperty, onRemove, xs, lg, md, sm, getLabel, disabled}: Props<T>): JSX.Element => {}
const MultiChips = <T,>({items, idProperty, labelProperty, onRemove, xs, lg, md, sm, getLabel, disabled}: Props<T,>): JSX.Element => {}

@AlexanderAbramovPav, the comma in <T,> and Props<T,> is needed and you do not want it be removed?

AlexanderAbramovPav commented 3 months ago

Yes, I wanna keep comma, cause I'm getting TS error otherwise

coderaiser commented 3 months ago

What kind of error? Could you please provide an example?

coderaiser commented 3 months ago
image

Also that's not supported by babel: https://astexplorer.net/#/gist/fa72ba4151ebd03e0d276486d1fed774/aa526bdca74d17a50fdba7d02894c5ac0ac3fb1b

Case 2: fixed in TSTypeParameterDeclaration @putout/printer@8.46.0 (🐊Putout Editor) 🎉.

Is it works for you?

AlexanderAbramovPav commented 3 months ago

For case 1

image

coderaiser commented 3 months ago

Re-install 🐊Putout, is it works for you?

AlexanderAbramovPav commented 3 months ago

Yes! Thank you a lot!