/** * What a module brings in: `import` bindings and their sources, `extern module` * declarations and the JavaScript types they carry, namespace imports, and the * migration report for the namespaces the language retired. * * D114 R1d: the import half of the module cluster. */ import { type ExternConstantDeclaration, type ExternFunctionDeclaration, type Program, type Statement, type TypeParameterDeclaration, type TypeReference } from "../../ast.ts"; import { type ClassInfo, type RetiredNamespace } from "../../contracts.ts"; import { type PermanentNamespaceName } from "../../core-vocabulary.ts"; import { type Diagnostic, type DiagnosticEdit, type DiagnosticFix } from "../../diagnostic.ts"; import { type Span } from "../../source.ts"; import { type EnumInfo, type GenericTypeInfo, type TypeParameterBound, type ValueType } from "../../types.ts"; import { type ClassRegistry } from "../classes/registry.ts"; import { type TypeReferences } from "../declarations/references.ts"; import { type Binding, type BuiltinTypeNamePosition } 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 ModuleImportsHost { builtin(name: string): Binding | null; declareBinding(name: string, mutable: boolean, type: ValueType, declarationSpan: Span, internal?: boolean, declaredType?: ValueType, importSource?: string, typeNamePosition?: BuiltinTypeNamePosition): void; readonly classDisplayNames: Map; readonly classRegistry: ClassRegistry; readonly classes: Map; readonly declaredNames: Set; readonly diagnostics: Diagnostic[]; readonly enums: Map; expandAliases(type: ValueType, seen?: ReadonlySet): ValueType; readonly externClassDeclarations: Map>; readonly externModules: Map>; readonly externTypeImports: Map; readonly genericTypes: Map; guidanceForGlobal(name: string): string | undefined; readonly importBindings: ReadonlyMap; readonly importedBindingOrigins: Map; readonly importedBindingSources: Map; markDeclaredBindingReactive(name: string, kind?: "state" | "prop"): void; readonly invalidExternTypeReferences: WeakSet; readonly namedTypeIdentities: Map; readonly namedTypes: Map>; readonly predeclared: WeakSet; readonly reactiveBindings: ReadonlyMap; resolveAnnotation(reference: TypeReference | null): ValueType; resolvedAsyncResult(type: ValueType): ValueType; readonly retiredNamespaceUses: { readonly namespace: string; readonly member: string | null; readonly span: Span; readonly memberEnd: number; readonly bare: boolean; }[]; readonly retiredNamespaces: Map; readonly scopes: Map[]; readonly typeAliases: Map; typeError(message: string, errorSpan: Span, fix?: DiagnosticFix): void; typeParameterBoundVector(declarations: readonly TypeParameterDeclaration[] | undefined): readonly (TypeParameterBound | null)[] | null; typeParameterFrame(declarations: readonly TypeParameterDeclaration[] | undefined): ReadonlyMap; readonly typeParameterFrames: ReadonlyMap[]; readonly typeReferences: TypeReferences; withTypeParameterFrame(frame: ReadonlyMap, action: () => T): T; } /** * Which reserved-type-name question an import specifier asks. A standard-module * import of the name under itself *is* the built-in surface — `velar/look` * republishes `Duration`, and the tour imports it that way — so only a binding * that would make the name mean something else is refused. That is the carve-out * D72 rule 186 already makes for `import {Color} from "velar/look"`; a module * scope import and a block-scoped one ask it here rather than each deciding it. */ export declare function importTypeNamePosition(statement: Extract, specifier: { readonly imported: string; readonly local: string; }): BuiltinTypeNamePosition | undefined; export declare class ModuleImports { analyzeImportDeclaration(statement: Extract): void; private readonly host; /** MD-U3: the local each `source`/`imported` pair first arrived under, module-wide. */ private readonly importedExportNames; /** CO-I1: the specifier spans that repeat an export this module already binds. */ readonly duplicateExportSpecifiers: Set; /** CO-I1: the export each named specifier binds, by span identity. */ readonly importSpecifierExportNames: Map; constructor(host: ModuleImportsHost); /** * The two facts about a module's import specifiers that later stages read * before any of them is declared: which JavaScript imports name an extern * class, and which specifiers repeat an export the module already binds. * * CO-I1: the duplicate index has to exist before `predeclareTopLevel` runs, * because the scope collision it answers is reported from `declareBinding`, * which sees a name and a source and cannot see the export behind them. */ registerImportSpecifiers(program: Program): void; /** * CO-I1: the two facts a scope collision reads off the import clauses — the * export each named specifier binds, and which specifiers bind an export some * earlier specifier in this module already bound. Namespace specifiers bind * no single export. The duplicate half excludes the JavaScript boundary for * the reason `analyzeImportDeclaration` gives — a checked import and an * unchecked one are two values — while the export names are recorded for * every clause, because the advice spells the export wherever the collision * is reported. */ private registerImportSpecifierExports; private registerExternTypeImports; registerExternModules(program: Program): void; importType(statement: Extract, local: string, imported: string, namespace: boolean, importSpan: Span): ValueType; externFunctionType(statement: ExternFunctionDeclaration, resolve?: (reference: TypeReference | null) => ValueType): ValueType; externConstantType(statement: ExternConstantDeclaration): ValueType; externClassIdentity(source: string, name: string): string; resolveExternAnnotation(reference: TypeReference | null, source: string, classNames: ReadonlySet): ValueType; crossBlockExternClassType(name: string): ValueType | null; resolveValidatedExternAnnotation(reference: TypeReference | null, source: string, classNames: ReadonlySet): ValueType; recordImportedBindingSource(javascript: boolean, source: string, local: string, imported: string | null): void; recordImportedBindingOrigin(local: string, source: string, specifierSpan: Span): void; displayExternalClasses(type: ValueType): ValueType; /** * The retired namespace whose module exports this bare name, when exactly one * does and no permanent namespace claims the same spelling. `min`, `max`, and * `clamp` are claimed by `Math.` as well, so those keep the guidance and lose * only the automatic rewrite — a fix has to be provably the author's meaning, * and there the meaning is genuinely ambiguous. */ retiredNamespaceOwning(name: string): string | null; /** The import line a migration writes, in the sorted shape every module here already uses. */ renderNamedImport(source: string, specifiers: readonly { readonly imported: string; readonly local: string; }[]): string; /** Where a module that has no import of `source` yet should grow one. */ importInsertion(program: Program, line: string): DiagnosticEdit; /** * D52 rule 114: the migration off a namespace prefix the language withdrew. * It is the mirror of the one below — that one takes an import away and puts * a prefix on, this one takes the prefix off and puts an import back — and * both answer in one step, because a migration that needs a second compile to * find the working spelling has taught a loop rather than a spelling. */ reportRetiredNamespaceUses(program: Program): void; /** A member name to show in the rule 106 guidance, so the fix is concrete. */ /** Every use of one retired namespace, reported together so one import line serves them all. */ private reportRetiredNamespace; /** * One diagnostic plan per use of a retired namespace prefix: the message, the * mechanical edit when there is one, and whether it needs the import line. */ private retiredNamespaceFixEntries; firstNamespaceMember(namespace: PermanentNamespaceName): string; } //# sourceMappingURL=imports.d.ts.map