/** * What a route accepts: the component a 'route(path, Component)' may name, the * path spellings a router can match, and the two accessibility readings a route * component's markup is asked for. * * D115 P4 R3a: 'web.route' asks these of an intrinsic context and the analyzer * asks them of a record of routes, so they read as a module both can call. * * D115 P4 R3c: the analyzer's own two — the `` list and the * component slot inside it — join them here, so the two callers differ only in * the environment they arrive with. */ import { type Diagnostic, type Span } from "@velarscript/compiler"; import { type CompilerIntrinsicAnalysisContext, type Expression, type ValueType } from "@velarscript/compiler/extension"; import { type WebJsxElementExpression as JSXElementExpression } from "../ast.ts"; /** * What the analyzer's two route readings ask of the analyzer that hosts them. * The intrinsic twins take a `CompilerIntrinsicAnalysisContext` instead: they * are called from inside an intrinsic, where that context is what the caller * already holds. */ export interface WebRouteHost { readonly diagnostics: Diagnostic[]; inferExpression(expression: Expression, contextualType?: ValueType): ValueType; /** * Assignability judged against the analyzer as the type environment. Asking * for the answer rather than for the environment keeps `TypeEnvironment` out * of this face. */ isAssignableHere(actual: ValueType, expected: ValueType): boolean; typeError(message: string, errorSpan: Span): void; } export declare function checkRouteComponent(type: ValueType, sourceSpan: Span, subject: string, context: CompilerIntrinsicAnalysisContext): void; export declare function checkRoutePath(path: string, sourceSpan: Span, report: (message: string, span: Span) => void): void; /** * The elements of a `` list literal, one at a time. * * A route written as `route("/a", Panel)` is checked at that call; the record * that call returns — `{path: "/a", component: Panel}` — is a legal spelling * of the same value, reaches the same runtime position, and until now was * checked by nothing: `{path: "no-leading-slash", component: 5}` compiled * clean and handed `5` to the Router as a component. Closing the sink rather * than the spelling means asking the same questions wherever a route arrives, * so this reports exactly what `route(...)` reports, word for word. * * The runtime is already the second referee (D90 R19): `routerTable` * validates every path and refuses a component that is not callable. Nothing * here changes which programs run — it moves a refusal the author would have * met at mount to the place the source shows the mistake. * * The `any` component slot is skipped here rather than inside * `checkWebRouteComponent`, which is why that function carries no `any` arm: * this loop and the Router `fallback` attribute are its only two callers, and * both filter first. An `any` reaches this slot for real — `web.lazy` answers * `anyType` from each of its error paths — and it arrives with the author's * real message already reported, so a second "received any" would be a * cascade. The `route(...)` twin skips it for the same reason. */ export declare function checkWebRouteRecords(host: WebRouteHost, expression: Expression): void; export declare function checkWebRouteComponent(host: WebRouteHost, type: ValueType, sourceSpan: Span, subject: string): void; export declare function containsPromise(type: ValueType): boolean; export declare function hasAccessibleJsxContent(expression: JSXElementExpression): boolean; export declare function hasAccessibleSvgName(expression: JSXElementExpression): boolean; //# sourceMappingURL=routes.d.ts.map