New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript typeof invalid formatting #14283
Comments
@fisker it will be much appreciated if we could have a config to disable this rule, |
@EladBezalel Could you show us codes that was broken by this change? This change is a just bug fix, so I'm wonder why your code is broken. |
The code has
on files that didn't changed |
@EladBezalel this is expected after upgrading from 2.8.2 to 2.8.3. See see #13546 and #14042. |
i understand this is expected, i suggest a config to disable it |
New config is not planned, according to the Prettier’s Option Philosophy. If you use Prettier via ESLint, I guess you can apply some fixes post-Prettier. However, it might be best to just stick with the new (improved) behavior and thus keep the codebase in sync with the community. It’s not so much about better or worse, it’s more about the same everywhere. |
As far as I can tell, #13546 doesn't provide any reasoning what's bad about I'm not against this, just curious why it is needed. (Would make sense to comment on the issue, but it is sadly locked.) |
This is confusing for ts beginner. |
I guess I can see how there is a small difference in readability. // Before
const a = [1];
const B = typeof a[0]; // B = 'number'
type A = typeof a[number]; // type A = number
// After
const a = [1];
const B = typeof a[0];
type A = (typeof a)[number]; But was there any data suggesting people found it confusing? Seems a bit arbitrary to just change this based on a hunch. |
I'm the beginner, prettier/yaml-unist-parser#281 (comment) |
Thanks, appreciate the history! const tuple = ['a', 'b'] as const;
type T = typeof tuple[number]; This is a pretty common pattern in TS, so a lot of people that installed Prettier in the last 3 years and update now will be wondering why they have to update their code :D |
Prettier 2.8.3
Playground link
Input:
Output:
Expected behavior:
see also https://steveholgado.com/typescript-types-from-arrays/
The text was updated successfully, but these errors were encountered: