import { type ReadonlyAdvisoryHost } from "../advisories/readonly.ts"; /** * A written type reference, validated: every syntax form a `TypeReference` can * take, checked against the records, aliases, enums, classes and generic * templates the module knows. * * D114 R1d: `validateTypeReference` was 240 lines of one `switch` inside one * closure. It keeps its exact shape — a recursive `validate` the extension * hook is asked first, then the switch — but each arm is now its own method, * so a reader who needs the `readonly` rule reads twenty lines instead of two * hundred and forty. `validateTypeReference` itself stays `protected` on * `Analyzer` and forwards here. */ import { type Expression, type TypeReference, type TypeSyntax } from "../../ast.ts"; import { type ClassInfo } from "../../contracts.ts"; import { type Diagnostic, type DiagnosticFix } from "../../diagnostic.ts"; import { type Span } from "../../source.ts"; import { type EnumInfo, type GenericTypeInfo, type ValueType } from "../../types.ts"; import { type Binding } from "../scopes.ts"; /** * Everything this half of the declaration cluster asks of the analyzer that * hosts it. The five halves share one host object, so the interface is the * same shape for each and the union of them is what the analyzer builds. */ export interface TypeReferencesHost extends ReadonlyAdvisoryHost { readonly bareGenericClassPositions: WeakSet; boundaryValidationGuidance(expression: Expression | null, property: string | null): string; classInfo(key: string): ClassInfo | undefined; readonly classes: Map; readonly diagnostics: Diagnostic[]; enclosingTypeParameterName(name: string): boolean; readonly enums: Map; readonly externClassDeclarations: Map>; readonly externTypeImports: Map; fieldsOf(identity: string): ReadonlyMap | null; readonly genericTypes: Map; readonly importBindings: ReadonlyMap; readonly invalidDeclaredTypes: Set; isPrimitiveType(name: string): boolean; lookup(name: string): Binding | null; readonly namedTypeIdentities: Map; readonly namedTypes: Map>; readonly namespaceImportLocals: Map; readonly primitiveNames: Set; rejectCollidingKeyDomain(keySource: ValueType, span: Span, position: string): void; reportPromiseCarrierHazard(type: ValueType, errorSpan: Span): void; resolveAnnotation(reference: TypeReference | null): ValueType; resolveGenericApplication(type: Extract, resolveArgument?: (argument: ValueType) => ValueType): ValueType | null; resolveGenericClassApplication(type: Extract): ValueType | null; staticMemberTypeParameters: { readonly className: string; readonly names: ReadonlySet; } | null; readonly typeAliases: Map; typeError(message: string, errorSpan: Span, fix?: DiagnosticFix): void; readonly typeParameterFrames: ReadonlyMap[]; readonly typeReferenceValidity: WeakMap; validateExtensionTypeSyntax(_syntax: TypeSyntax, _validate: (syntax: TypeSyntax) => boolean, _resolve: (reference: TypeReference) => ValueType): boolean | undefined; validateGenericApplication(info: GenericTypeInfo, syntax: Extract): boolean; validateGenericClassApplication(name: string, info: ClassInfo, syntax: Extract): boolean; } export declare class TypeReferences { private readonly host; constructor(host: TypeReferencesHost); validateTypeReference(reference: TypeReference, resolve?: (reference: TypeReference) => ValueType): boolean; /** A bare name: a primitive, a record, an alias, a class, an enum, a type parameter — or nothing. */ private validateNamedTypeSyntax; /** `Enum.member` in a type position, and the namespace-import spellings that are not one. */ private validateEnumMemberTypeSyntax; /** An application `Name`: the template, its arguments, and the built-in constructors. */ private validateGenericTypeSyntax; /** A qualifier protects this data surface; nested values keep their own contracts. */ private validateReadonlyTypeSyntax; resolveNamedClasses(type: ValueType): ValueType; } //# sourceMappingURL=references.d.ts.map