[consistent-type-assertions] Type assertions in return statements #8850
Replies: 2 comments 5 replies
-
@rfgamaral If I understand the options and config you're using correctly, just wrapping the ternary in parentheses seems to solve the issue. (if not, consider putting a playground link with your options to help elucidate the issue) |
Beta Was this translation helpful? Give feedback.
-
Please note that we don't use discussions for technical support or bug reports. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I wanted to follow up on this issue, but I can't comment there because the conversation is limited to collaborators.
I have this use case:
This is implemented with the
consistent-type-assertions
rule being enforced. But, as the referenced issue requested, I too would like to remove the intermediaryresult
variable. However, the way the original issue described the intermediaryresult
variable is different from this example. Unfortunately, I cannot do this:I get this error:
Since this is a TypeScript error, and not an ESLint one, what I'm looking to do is something like this:
But I can't, the
consistent-type-assertions
rule does not let me.The issue was closed with an update to the documentation to clarify that a new option is probably not needed. But I believe this use case proves otherwise. By no means, I'm an expert on this topic (either ESLint or TypeScript types), so I could be wrong, but for this particular use case, I don't think there's an alternative to the intermediary
result
variable.With this discussion, I'm aiming for one of two things:
Beta Was this translation helpful? Give feedback.
All reactions