Repository navigation
feat(analyzer): analyse composables in .uf.ts modules - #71
Merged
Merged
Conversation
A `.uf.ts` module's named `use*` exports are composables (ADR-0069). Each body is declared and lowered by the component setup's own pass, with parameters read as `argument` bindings in place of props and a returned shorthand object in place of JSX. The module's IR holds `UfComposable`, and its API a `ComposableApi` per composable, with each member's kind, the flags of its functions and `hasEffects`. UF2035 reports each form ADR-0069 rejects, at its span: the APIs that need a component, a call of another composable, a default export, a return of any other shape, and parameters a target cannot read by kind. Co-authored-by: multica-agent <github@multica.ai>
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://composables-analysis-uxf-458-unframework.blue-water-0397.workers.dev (commit d5b273b)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
A reserved parameter name is UF2003, a member returned twice, a function type written through an alias or a union, a `this` parameter and a value import of a `.uf.ts` module that no composable calls are UF2035. Type specifiers of a `.uf.ts` import are re-imported. A function that calls a callback is client code: impure where a getter or an initial value calls it (UF2014), and `client` in the API. Co-authored-by: multica-agent <github@multica.ai>
A read of a composable's parameter records no narrowing: only a prop's or a ref's value's read narrows in the IR. A parameter typed `Function` or a call signature, in place or through the module's aliases and interfaces, is UF2035, as a function type through an alias is. The fix for a member returned twice starts at the property before it, and UF2020's fix calls an optional getter with `?.()`. Co-authored-by: multica-agent <github@multica.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
The analyser reads a
.uf.tsmodule of composables (ADR-0069).analyze()takes a.uf.tsmodule as well as a.uf.tsxone. A.uf.tsmodule holds no component. Each named exportuse[A-Z]…, a function declaration, is a composable, lowered intoUfModule.composables.declareSetup), with its parameters in place of props and a returned shorthand object in place of JSX. A component's rules apply to it as they do to a setup.argumentbinding as a destructured prop is read. Its type, written in place, gives its kind: a function type without parameters is a getter, any other function type a callback, and anything else a value. A function type through an alias or a union is UF2035, and a name a target reserves is UF2003. Watching a getter by name is UF2020, with a safe fix to() => value().ComposableApiper composable: each parameter's kind and type, each member's kind and its type where the source writes one, whether a returned function isasync, andpureorclientby its summary (a function that calls a callback is client code, and UF2014 where a getter or an initial value calls it), andhasEffectswhere the setup holds a watcher or a lifecycle hook.useId,useTemplateRef,provide,injector adefine*macro;.uf.tsor declared in the module;thisparameter, a value import of a.uf.tsmodule that no composable calls, a parameter without a type, with a default or written as a pattern, a callback read outside client code, ause*function the module keeps or writes as a value, an export named otherwise, anasynccomposable, and a module that exports no composable..uf.tsimport, inline or whole, are re-imported (typeImports)..uf.tsmodule is UF1002: it stays in the.uf.tsxmodule that provides it (ADR-0054).The call site and
compile()'s handling of a.uf.tssource come in a later change. Framework output: no output changes on any target, and no corpus case changes.Checklist
feat(web): sell the next framework on the homepage.pnpm format:check,pnpm lint,pnpm check-typesandpnpm testpass. The first three pass. The analyser's, the compiler's and the repo tests pass, and so does the full integration suite on all seven targets, with the parity matrix green. The rootpnpm testwas not run as one command.pnpm changeset(see.changeset/README.md). Not needed: every package is private.pnpm build, thenpnpm --filter web lighthouse, still scores at least 0.95 in every category. Not needed: no homepage change.