{{! 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 needsParens=true}} {{/each}} {{#if needsParens}} ) {{/if}} {{/inline}} {{#*inline 'intrinsic'}} {{name}} {{/inline}} {{#*inline 'literal'}} {{stringify value}} {{/inline}} {{#*inline 'mapped'}} { {{#ifCond readonlyModifier '===' '+'}} readonly {{else}} {{#ifCond readonlyModifier '===' '-'}} -readonly {{/ifCond}} {{/ifCond}} [ {{parameter}} in {{#with parameterType}} {{>type}} {{/with}} {{#with nameType}} as {{>type}} {{/with}} ] {{#ifCond readonlyModifier '===' '+'}} ?: {{else}} {{#ifCond readonlyModifier '===' '-'}} -?: {{else}} : {{/ifCond}} {{/ifCond}} {{#with templateType}} {{>type}} {{/with}} } {{/inline}} {{#*inline 'optional'}} {{#with elementType}} {{> type}} {{/with}} ? {{/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'}} {{#with getReflection }} {{name}} {{else}} {{name}} {{/with}} {{#if typeArguments}} < {{#each typeArguments}} {{#unless @first}} , {{/unless}} {{> type}} {{/each}} > {{/if}} {{/inline}} {{#*inline 'reflection'}} {{#if declaration.children}} {{! object literal }} { {{#each declaration.children}} {{#unless @first}} ; {{/unless}} {{#if getSignature}} {{#if setSignature}} {{name}} : {{#with getSignature.type}} {{> type}} {{else}} any {{/with}} {{else}} get {{name}} (): {{#with getSignature.type}} {{> type}} {{else}} any {{/with}} {{/if}} {{else}} {{#if setSignature}} set {{name}} ( {{! Rather hacky to use each here... but we know there is exactly one. }} {{#each setSignature.parameters}} {{name}} : {{#with type}} {{> type}} {{else}} any {{/with}} {{/each}} ) {{else}} {{name}} {{#if flags.isOptional }} ?: {{else}} : {{/if}} {{#with type}} {{> type}} {{else}} any {{/with}} {{/if}} {{/if}} {{/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 'rest'}} ... {{#with elementType}} {{> type}} {{/with}} {{/inline}} {{#*inline 'tuple'}} [ {{#each elements}} {{#unless @first}} , {{/unless}} {{> type}} {{/each}} ] {{/inline}} {{#*inline 'template-literal'}} ` {{#if head}} {{head}} {{/if}} {{#each tail}} ${ {{#with this.[0]}} {{>type}} {{/with}} } {{#if this.[1]}} {{this.[1]}} {{/if}} {{/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}} {{#*inline 'named-tuple-member'}} {{name}} {{#if isOptional}} ?: {{else}} : {{/if}} {{#with element}} {{> type}} {{/with}} {{/inline}} {{#if this}} {{> (lookup . 'type') }} {{else}} void {{/if}}