/** * What a module publishes: the re-export forms, and D90 R12's rule that a * public surface may not carry an inferred `any` out of the module. * * D114 R1d: the export half of the module cluster. */ import { type BindingPattern, type Program } from "../../ast.ts"; import { type Diagnostic, type DiagnosticFix } from "../../diagnostic.ts"; import { type Span } from "../../source.ts"; import { type ValueType } from "../../types.ts"; import { type ClassRegistry } from "../classes/registry.ts"; import { type AnalyzableFunctionDeclaration } from "../functions.ts"; import { type Binding } from "../scopes.ts"; /** * Everything this half of the module cluster asks of the analyzer that hosts * it. The three halves share one host object. */ export interface ModuleExportsHost { readonly classRegistry: ClassRegistry; collectPatternNames(pattern: BindingPattern, add: (name: string) => void): void; readonly diagnostics: Diagnostic[]; readonly exportPositionCandidates: { readonly className: string; readonly member: string; readonly span: Span; }[]; readonly namedTypes: Map>; readonly scopes: Map[]; readonly typeAliases: Map; typeError(message: string, errorSpan: Span, fix?: DiagnosticFix): void; } export declare class ModuleExports { private readonly host; constructor(host: ModuleExportsHost); validateReExports(program: Program): void; /** * D90 R12: "exported" is a property of the declaration a consumer can reach, * not of the `def` keyword. A module-level declaration carries the flag * itself and is judged here and now. A class member carries none — a public * member of a class this module publishes is read by a consumer exactly as * an exported `const` is — but whether the class is published is a question * about the whole module, so the member waits for reportExportPositionAny. A * `private` member is never reachable, and R12's boundary does not move: * module-internal `any` stays legal. */ recordExportedAny(statement: AnalyzableFunctionDeclaration, className: string | null, span: Span): void; /** * D90 R12: the class members that turned out to be at an export position. * Reported once the module is analyzed, because the answer is reachability * and reachability is a property of the module, not of the declaration. */ reportExportPositionAny(program: Program): void; /** * D90 R12: which class declarations a consuming module can reach. Exported * classes seed the set; from there it follows every position a consumer can * read a value *out of* — the type of anything else this module exports, the * base a reachable class names, and the public surface of a class already * reachable. `export class Box extends Base:` publishes `Base`'s members, * and `def make() -> Inner` publishes `Inner`'s, whether or not either name * is exported. * * Input positions are deliberately absent, for the same reason * `typeContainsAnyOutput` omits them: a consumer that has to *supply* an * instance obtained it from an output position first, and that position is * what makes the class reachable. */ exportReachableClasses(program: Program): ReadonlySet; /** * D90 R12: the diagnostic has to teach the way out, not only refuse. A * consuming module never writes `unsafe`, so an exported `any` hands it a * value carrying no guarantee at all; the escape is to validate the value * into a declared type in the module that owns the boundary, which is what * `Type.parse` exists for. No new diagnostic code and no unsafe marker: this * is the rule at validateTypeReference finished, not a second rule. */ reportExportedAny(exported: readonly string[], span: Span): void; } //# sourceMappingURL=exports.d.ts.map