Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement printer cases for TS{Conditional,Infer}Type.
Although (infer T) must frequently be parenthesized to avoid ambiguity, Recast does not have to encode that logic into FastPath#needsParens, because Babylon wraps such types with TSParenthesizedType. Cool! babel/babel#7404 benjamn/ast-types@da0367b microsoft/TypeScript#21316 microsoft/TypeScript#21496
- Loading branch information
eb043a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In hindsight, what I said about
TSParenthesizedType
was not really the good news I imagined, since obviously Recast will sometimes need to add parentheses when printing types likeTSInferType
, if not adding them would cause the code to parse incorrectly/differently. But at leastTSParenthesizedType
provides an AST-level tool that TypeScript developers can use to add parentheses explicitly—even/especially when they are “unnecessary” and only serve to signal the programmer’s intent.