/** * The predicate a runtime `Type` is: what one value must satisfy to be that * type, the generic instance a `Type` is applied at, and the traversal guard * a recursive declaration needs so a checker cannot loop. * * D114 R1c: `emitTypeCheck`, `emitIsCheck` and `emitNarrowingCheck` are still * declared on `JavaScriptEmitter` — Web overrides the first two — and forward * here. */ import type { TypeAliasDeclaration, TypeDeclaration, TypeSyntax, TypeReference } from "../ast.ts"; import { type GenericApplication, type ValueType } from "../types.ts"; import { type LoweringHints } from "../contracts.ts"; import { ModuleAccessEmitter } from "./module-access.ts"; export interface TypeCheckEmitterHost { genericTypeBinding(name: string): boolean; genericTypeParameters: readonly string[] | null; readonly hints: LoweringHints; readonly hoistedGenericInstances: Map; needsAssertionErrorClass: boolean; needsCollectionHelpers: boolean; needsNarrowingErrorClass: boolean; needsRuntimeTypeHelpers: boolean; nominalRuntimeReceiver(type: Extract): string | null; readonly requiredHostErrorClasses: Set; runtimeTypeBinding(name: string): boolean; readonly runtimeTypeTraversalGuards: Map; readonly typeCheckDeclarations: string[]; readonly typeDeclarations: Map; } export declare class TypeCheckEmitter { private readonly host; readonly modules: ModuleAccessEmitter; private readonly structuralChecks; constructor(host: TypeCheckEmitterHost); emitTypeCheck(type: ValueType, value: string, state?: string): string; emitIsCheck(type: ValueType, value: string): string; emitNarrowingCheck(type: ValueType, value: string, state?: string): string; private emitObjectTypeCheck; runtimeTypeCheckName(name: string): string; /** The instantiation a `named` application stands for, as a JavaScript expression. */ genericInstanceExpression(application: GenericApplication): string; /** * A type argument's memo key or display text. Both are plain strings when the * argument is closed; inside a generic body a mention of the enclosing * parameters reads them off the arguments the instantiation supplied, so * `type Wrapper: inner: Box>` keys and prints correctly at every * instantiation without the emitter having seen one. */ private genericArgumentExpression; /** * The display text of a field's declared type, as a JavaScript expression. * A generic record's `parse` failure names the type the caller instantiated * — `field 'value' does not match string`, not `does not match T`. */ typeTextExpression(type: ValueType, syntax: TypeSyntax | null): string; /** * A declared type inside a generic record's body. The emitter has no analyzer * frame, so the declaration's own parameter names are turned into `parameter` * kinds here — the one place the emitter learns that `T` is erased rather * than unknown. */ resolveDeclarationType(reference: TypeReference): ValueType; private importedTypeReceiver; private importedTypeIsFactory; /** The Type object expression for a source-visible record name or application. */ runtimeTypeObjectExpression(type: ValueType): string | null; /** * Acyclic declared type graphs have a statically bounded walk, even when the * JavaScript data itself contains a cycle: every recursive check consumes one * layer of the finite type. Only a declaration cycle, an erased generic, or * an imported runtime Type needs the shared WeakMap/Set traversal guard. */ runtimeTypeNeedsTraversalGuard(name: string): boolean; private declarationNeedsTraversalGuard; private typeNeedsTraversalGuard; /** The runtime class behind a nameable builtin error type, marking the runtime it needs. */ builtinErrorRuntimeName(name: string): string | null; /** The enum an alias (or alias chain) resolves to, or null when the name is not an alias of an enum. */ enumAliasTarget(name: string, seen?: readonly string[]): string | null; } //# sourceMappingURL=type-checks.d.ts.map