Description
Bug Report
Typescript Language Formatter function removes parentheses ()
from the declared type on hovering over it.
Not a bug with the Typescript parser itself.
🔎 Search Terms
infer, conditional typing, parentheses, hover
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about parentheses getting removed for conditionally inferring types
⏯ Playground Link
Playground link with relevant code
💻 Code
type Tail<T extends any[]> = ((...t: T) => void) extends (
h: any,
...rest: infer R
) => void
? R
: never;
🙁 Actual behavior
Wrapped ()
gets removed on hovering from the declared conditional inferring type.
Because of this the hovered type shown is not the same as the declared type and they are not interchangeable and can cause bugs.
Without parenthesis, the TS parses it as a Type which returns a Function and the return type of the function is that conditional "void extends ..."
which is not what was declared.
🙂 Expected behavior
()
should be preserved and shown while hovering so to prevent the errors that can arise because of missing ()
in the conditional inferring types