-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.type:testsIssues about tests that are not correct, should be added, or similarIssues about tests that are not correct, should be added, or similar
Description
Prettier 2.7.1
Playground link
--parser typescript
Input:
export class Foo<T> {
}
function sample(error: unknown) {
if (!(error instanceof Foo<'some-type'> || error instanceof Error) || !error.message) {
return 'something';
}
}
Output:
SyntaxError: Expression expected. (5:43)
3 |
4 | function sample(error: unknown) {
> 5 | if (!(error instanceof Foo<'some-type'> || error instanceof Error) || !error.message) {
| ^
6 | return 'something';
7 | }
8 | }
Expected behavior:
3 |
4 | function sample(error: unknown) {
5 | if (
6 | !(error instanceof Foo<'some-type'> || error instanceof Error) ||
7 | !error.message
8 | ) {
6 | return 'something'
7 | }
8 | }
It works if I wrap Foo<'some-type'> with parentheses and then prettier formats it like expected behavior (also removes edit: problem occured again on reformat (obviously)( )
) but I think it should work without wrapping.
It works if I split that logical OR into separate statements (I know this is not logically the same as above, just for an example)
!(error instanceof Foo<'some-type'>) ||
!(error instanceof Error) ||
!error.message
Metadata
Metadata
Assignees
Labels
locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.type:testsIssues about tests that are not correct, should be added, or similarIssues about tests that are not correct, should be added, or similar