/** * The retired 'computed(...)' accessor: the intrinsic a call around it is still * typed by, and the shape of one declaration held for the migration message. * * D115 P4 R3a: a frozen table and a record shape, read by the analyzer and by * the intrinsic that types the call, so they read as a module. * * D115 P4 R3c: the migration pass itself joins them — what one declaration * records, what one read records, and the one message per site the whole-program * report writes — over a `RetiredAccessorHost`. */ import { type Diagnostic, type Span } from "@velarscript/compiler"; import { type Expression, type Statement, type ValueType } from "@velarscript/compiler/extension"; /** * `computed(...)` the function is answered with the signature it always had, so * a call written around it still type-checks instead of collapsing into an * unknown one — that is what keeps the one message about the declaration form * the only thing the author reads. `reactive.computed` itself is gone; this one * derives no reactivity and is never emitted, because every site that produces * it also produces an error. It stays an intrinsic only so the reader it * returns carries the callback's own result: an annotated declaration — * `const one: () -> number = computed(() => 1)` — would otherwise read a * second, spurious assignability error on top of it. */ /** * What the D71 migration off `computed(...)` the function asks: the four tables * it fills while the module is walked and reads once the walk has ended, and * the lookup that tells a global accessor apart from a binding of the name. */ export interface RetiredAccessorHost { /** Callee spans already claimed by a recognised `const x = computed(...)` declaration. */ readonly migratedComputedCallees: Set; /** Callee span identity -> call span, for every zero-argument call of a plain name. */ readonly plainCallSpans: Map; readonly retiredAccessorDeclarations: Map; readonly retiredAccessorReads: Map; readonly retiredComputedReferences: Map; readonly diagnostics: Diagnostic[]; lookup(name: string): { readonly span: Span; readonly type: ValueType; } | null; } export declare const RETIRED_ACCESSOR_INTRINSIC = "reactive.retired-accessor"; export declare const RETIRED_ACCESSOR_TYPE: ValueType; export interface RetiredAccessorDeclaration { readonly name: string; readonly exported: boolean; /** The named function the argument reads through, when it is one — `computed(readA)`. */ readonly readName: string | null; readonly declarationSpan: Span; readonly callSpan: Span; /** The `() => E` body span, or null when the argument is not that shape. */ readonly bodySpan: Span | null; } /** * D71 rule 183: `computed(...)` the function — the shape Vue and the signals * libraries teach — is not how a derived value is written here; the `computed` * declaration is. The declaration is recorded before the core walks the module * so its reads can be matched against it — the rewrite that removes the call * parentheses is only offered when every read is a plain `x()`. */ export declare function recordRetiredAccessorDeclaration(host: RetiredAccessorHost, statement: Extract): void; /** Returns true when the name is one of the retired accessor globals this pass owns. */ export declare function recordRetiredAccessorRead(host: RetiredAccessorHost, expression: Extract): boolean; /** * D71 migration: one message per site, and a mechanical rewrite only where * the compile can prove the rewrite. Where the * accessor is used as a value there is no second spelling left to offer, so * that site is told to declare the value and write an ordinary `def` where a * callable is what the caller wants — and it gets no edit, because moving a * reader out of a value position is the author's decision. */ export declare function reportRetiredComputedFunction(host: RetiredAccessorHost): void; //# sourceMappingURL=retired-accessors.d.ts.map