Dec. 16, 2021
8:03 p.m.
I think there's a pretty good reason to disallow it. We definitely want `|` to bind tighter than `->` because using union and optional types in the return position will be very common. If we do that, then the obvious grammar rules make `|` unions of un-parenthesized callable types illegal as an artifact of PEG grammar. It's probably possible to special-case it but I think making the precedence of `|` versus `->` order-dependent would be very questionable. Plus, since the `None` is conventionally a suffix in `X | None` types, it wouldn't help that much anyway. I think TypeScript is doing the right thing here. We can definitely use invalid_ grammar rules to customize our error messages, much as Eric says TypeScript does