/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import ts from 'typescript'; import { ClassDeclaration, ReflectionHost } from '../../reflection'; import { TypeCtorMetadata } from '../api'; import { ReferenceEmitEnvironment } from './reference_emit_environment'; export declare function generateTypeCtorDeclarationFn(env: ReferenceEmitEnvironment, meta: TypeCtorMetadata, nodeTypeRef: ts.EntityName, typeParams: ts.TypeParameterDeclaration[] | undefined): ts.Statement; /** * Generate an inline type constructor for the given class and metadata. * * An inline type constructor is a specially shaped TypeScript static method, intended to be placed * within a directive class itself, that permits type inference of any generic type parameters of * the class from the types of expressions bound to inputs or outputs, and the types of elements * that match queries performed by the directive. It also catches any errors in the types of these * expressions. This method is never called at runtime, but is used in type-check blocks to * construct directive types. * * An inline type constructor for NgFor looks like: * * static ngTypeCtor(init: Pick, 'ngForOf'|'ngForTrackBy'|'ngForTemplate'>): * NgForOf; * * A typical constructor would be: * * NgForOf.ngTypeCtor(init: { * ngForOf: ['foo', 'bar'], * ngForTrackBy: null as any, * ngForTemplate: null as any, * }); // Infers a type of NgForOf. * * Any inputs declared on the type for which no property binding is present are assigned a value of * type `any`, to avoid producing any type errors for unset inputs. * * Inline type constructors are used when the type being created has bounded generic types which * make writing a declared type constructor (via `generateTypeCtorDeclarationFn`) difficult or * impossible. * * @param node the `ClassDeclaration` for which a type constructor will be * generated. * @param meta additional metadata required to generate the type constructor. * @returns a `ts.MethodDeclaration` for the type constructor. */ export declare function generateInlineTypeCtor(env: ReferenceEmitEnvironment, node: ClassDeclaration, meta: TypeCtorMetadata): ts.MethodDeclaration; export declare function requiresInlineTypeCtor(node: ClassDeclaration, host: ReflectionHost, env: ReferenceEmitEnvironment): boolean;