/** * How the visual unit types combine — the rule `+` reads, and the rule the * length-percentage builders read. * * D115 §三: one question about types, asked in two places, so it is written * once here rather than twice in the middle of the Web analyzer. */ import { type Diagnostic } from "@velarscript/compiler"; import { type Expression, type Span, type ValueType } from "@velarscript/compiler/extension"; export declare function isLookNumericType(type: ValueType): boolean; /** * The type two visual operands add up to: the same kind on both sides keeps it, * and a length beside a percentage widens to the type that carries both. */ export declare function lookAdditiveType(left: ValueType, right: ValueType, sameIdentity: boolean): ValueType | null; /** * D114 0.29.0 LK-C3: `min`, `max` and `clamp` publish the widest of the three * length-percentage types, because a slot takes either. A call whose slots are * all one kind is still that kind, and the fold is the one `+` already makes. * Without it, `clamp(16px, 3vw, 24px)` — the tour's own line, and a legal * `lineHeight` — would have started answering `LengthPercentage` and stopped * assigning. * * `inferSlot` both infers a slot and remembers the answer, because the call's * own analysis reads each argument again straight afterwards and must not * report the argument's diagnostics a second time. */ export declare function foldedLengthPercentage(expression: Extract, builderOf: (name: string) => string | undefined, inferSlot: (argument: Expression) => ValueType, join: (left: ValueType, right: ValueType) => ValueType | null): ValueType | null; /** * Where the bare number a builder slot refused is actually written, and the * binding it came through when that is not the argument itself. * * D114 F9-web (WB-I7): `hsl(210, sat, 45%)` under `const sat = 70` folds to a * number, and the report was drawn under `sat` while its remedy said `70%` — so * an author editing at the caret replaced the binding's use with a literal. The * number is written in the binding's initializer, so that is where the caret * goes, and the sentence names the binding so the line it lands on is explained. * A constant imported from another module has no site here and keeps the * argument's own span, which is the only position this compile can point at. */ export type LookStaticSites = ReadonlyMap; /** * D114 P6 item 2 (LK-I3): a bare number written where a builder slot takes a * `Percentage`. * * The refusal already exists and is already in the right place — it is core's * assignability check on the argument — so this teaches that one the remedy * instead of adding a second report of one mistake. The message names the * percentage the author meant, and `velar fix` writes it where the argument is * a literal; an identifier that folded to a number is a binding whose * declaration is the place to change, so it earns the sentence there and no * rewrite — retyping the binding is not a mechanical edit, because every other * use of it is part of the answer. * * Returns whether the refusal was found and taught. */ export declare function teachLookPercentageSlot(diagnostics: Diagnostic[], slot: string, argument: Expression, literal: number, sites: LookStaticSites): boolean; /** * D114 F7-web-b: a bare number written in a builder slot that will not take * one — the mistake LK-I3 found on `hsl`, which on the length builders had been * left drawing two reports about one number: core's `Cannot assign number to * Length` and this analyzer's unit advice, side by side. * * Which slots those are is the builder's own published type, handed in by the * caller, so there is no second table of builder positions kept in step by * hand. Three shapes, three lessons: * * - a slot whose type is exactly `Length` — `blur`'s radius, `border`'s * width, the offsets and spread of `shadow` and `dropShadow` — has one * natural unit, so the sentence names it and `velar fix` writes `4px`; * - a slot that takes a length *or* a percentage — `min`, `max` and `clamp`, * the three builders that exist to mix them — names both spellings and * offers no rewrite, because `100px` and `100%` are different pictures and * the one the author meant is not the compiler's to guess; * - a slot whose union admits `number` as well — `spacing`, `tracks`, * `minmax` — draws no refusal from core at all, so the unit advice is the * whole diagnosis, and zero passes because that union really does take it. * * D114 F9-web (WB-I2): all three sentences are one sentence, built from the * slot's own published type, because the advice used to be written twice. The * unit advice said "(only 0 is unitless)" for every builder that composes * lengths — true of the third shape, whose union takes a bare `0`, and a * falsehood on `blur` and `shadow`, where `blur(0)` is refused. A slot cannot * now be told what it takes by anything but its type: `slotAccepts` reads it, * and the "or 0" clause exists exactly where a bare number is accepted. * * Zero is refused in the first two: `blur(0)` and `min(0, 600px)` are not CSS, * so the slot says what to write. A slot that admits no length at all — a * colour, a border style, `inset` — is not this rule's business and earns * nothing here. * * D114 WB-X1: `declared` is the builder's whole published type rather than one * slot of it, because a rest parameter's type is the type of every position it * collects and reading `parameters[position]` stopped at the last named one. * `tracks(4, 8px)` was refused and `tracks(8px, 4)` drew nothing at all — the * second argument of a builder whose signature declares one parameter had no * published type to read, so the lesson never ran there. * * Returns whether the argument was refused here, which is the caller's record * that this call failed its own argument check. */ export declare function teachLookLengthSlot(diagnostics: Diagnostic[], builder: string, position: number, declared: ValueType, argument: Expression, literal: number, sites: LookStaticSites): boolean; /** * D114 F10-web (0.32.0 ledger WB-I1): the other rest builder's slot lesson. * * `tracks` and `filters` are the two rest builders in the look vocabulary, and * the first of them got a lesson in the X wave while the second kept core's bare * assignability refusal — `Cannot assign number to Filter`, which names no slot, * offers no remedy, and leaves an author who has read `filters(blur(4px), 3)` * with nowhere to look up what a `Filter` is made of. One vocabulary, one kind * of report. * * The lesson is the same shape as the length one and taught into the same * refusal, so it is still one report for one mistake. It names no rewrite: * `blur(4px)` and `grayscale(0.3)` are different pictures, and which of the ten * the author meant is not the compiler's to guess — the same reason the * length-or-percentage slot offers none. * * Returns whether the refusal was found and taught. */ export declare function teachLookFilterSlot(diagnostics: Diagnostic[], builder: string, position: number, declared: ValueType, argument: Expression): boolean; //# sourceMappingURL=look-values.d.ts.map