{{! Each type gets its own inline helper to determine how it is rendered. }}
{{! The name of the helper is the value of the 'type' property on the type.}}
{{!
The type helper accepts an optional needsParens parameter that is checked
if an inner type may result in invalid output without them. For example:
1 | 2[] !== (1 | 2)[]
() => 1 | 2 !== (() => 1) | 2
}}
{{#*inline 'array'}}
{{#with elementType}}
{{> type needsParens=true}}
[]
{{/with}}
{{/inline}}
{{#*inline 'conditional'}}
{{#if needsParens}}
(
{{/if}}
{{#with checkType}}
{{> type needsParens=true}}
{{/with}}
extends
{{#with extendsType}}
{{> type}}
{{/with}}
?
{{#with trueType}}
{{> type}}
{{/with}}
:
{{#with falseType}}
{{> type}}
{{/with}}
{{#if needsParens}}
)
{{/if}}
{{/inline}}
{{#*inline 'indexedAccess'}}
{{#with objectType}}
{{> type}}
{{/with}}
[
{{#with indexType}}
{{> type}}
{{/with}}
]
{{/inline}}
{{#*inline 'inferred'}}
infer {{name}}
{{/inline}}
{{#*inline 'intersection'}}
{{#if needsParens}}
(
{{/if}}
{{#each types}}
{{#unless @first}}
&
{{/unless}}
{{> type}}
{{/each}}
{{#if needsParens}}
)
{{/if}}
{{/inline}}
{{#*inline 'intrinsic'}}
{{name}}
{{/inline}}
{{#*inline 'predicate'}}
{{#if asserts}}
asserts
{{/if}}
{{name}}
{{#if targetType}}
is
{{#with targetType}}
{{>type}}
{{/with}}
{{/if}}
{{/inline}}
{{#*inline 'query'}}
typeof
{{#with queryType}}
{{> type}}
{{/with}}
{{/inline}}
{{#*inline 'reference'}}
{{#if reflection}}
{{reflection.name}}
{{else}}
{{name}}
{{/if}}
{{#if typeArguments}}
<
{{#each typeArguments}}
{{#unless @first}}
,
{{/unless}}
{{> type}}
{{/each}}
>
{{/if}}
{{/inline}}
{{#*inline 'reflection'}}
{{#if declaration.children}} {{! object literal }}
{
{{#each declaration.children}}
{{#unless @first}}
;
{{/unless}}
{{name}}
{{#if flags.isOptional }}
?:
{{else}}
:
{{/if}}
{{#with type}}
{{> type}}
{{else}}
any
{{/with}}
{{/each}}
}
{{else if declaration.signatures}}
{{#if (lookup declaration.signatures 1) }} {{! more than one signature}}
{
{{#each declaration.signatures}}
{{> member.signature.title hideName=true}}
{{#unless @last}}
;
{{/unless}}
{{/each}}
}
{{else}}
{{#if needsParens}}
(
{{/if}}
{{#with (lookup declaration.signatures '0') }}
{{> member.signature.title hideName=true arrowStyle=true}}
{{/with}}
{{#if needsParens}}
)
{{/if}}
{{/if}}
{{else}}
{}
{{/if}}
{{/inline}}
{{#*inline 'stringLiteral'}}
"{{value}}"
{{/inline}}
{{#*inline 'tuple'}}
[
{{#each elements}}
{{#unless @first}}
,
{{/unless}}
{{> type}}
{{/each}}
]
{{/inline}}
{{#*inline 'typeOperator'}}
{{operator}}
{{#with target}}
{{> type}}
{{/with}}
{{/inline}}
{{#*inline 'typeParameter'}}
{{name}}
{{/inline}}
{{#*inline 'union'}}
{{#if needsParens}}
(
{{/if}}
{{#each types}}
{{#unless @first}}
|
{{/unless}}
{{> type needsParens=true}}
{{/each}}
{{#if needsParens}}
)
{{/if}}
{{/inline}}
{{#*inline 'unknown'}}
{{name}}
{{/inline}}
{{#if this}}
{{> (lookup . 'type') }}
{{else}}
void
{{/if}}