mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Outside of JSDoc comments, postfix-? is parsed at lower precedence than the `?` of conditional types, and a postfix-? inside a tuple type results in the type being marked optional. This PR changes JSDoc parsing to behave the same way, which means that 1. Conditional types are allowed in JSDoc. Fixes #37166. 2. Tuple types' postfix-? syntax is interpreted correctly in JSDoc. Fixes #38747. The breaking change is that a postfix-? type followed by another postfix type, like `[]` or `!`, is parsed as a conditional type. [Postfix-? is not common](https://github.com/microsoft/TypeScript/issues/37166#issuecomment-612274456), so this is an acceptable breaking change. A postfix-? type `T?` is still parsed everywhere else and treated as `T | null`.