Repository navigation
[IMP] owl-core, owl-compiler: type the scope's app and the template contract - #2081
Merged
Merged
Conversation
mcm-odoo
force-pushed
the
master-template-contract-mcm
branch
from
November 27, 2026 12:06
b488a1e to
0d8cf0e
Compare
Scopes carry the application they belong to, so that plugins and components can reach it (e.g. to create new roots). The concrete App lives in owl-runtime, so core typed it as `any`. Core actually only reads two things from it: its plugin manager and its dev mode. This describes them in a `ScopeApp` interface, used by Scope, PluginManager and core's `useApp`. owl-runtime narrows it back: ComponentNode declares its `app` as an App, and runtime's `useApp` still returns an App.
A compiled template is created with `(app, bdom, helpers)` and calls the blockdom functions and helpers it receives. Which functions exist and how they are called was only an agreement between the code generator and owl-runtime: renaming a helper or changing its arguments on one side broke only when a template using it was rendered. The contract is now described by two types in owl-compiler, TemplateBlockDom and TemplateHelpers, and used on both sides: - the code generator only accepts helper and blockdom names from them; - owl-runtime's helpers and bdom objects must satisfy them. Values the generated code only passes along (contexts, nodes, blocks, the app) stay `any`: their shape belongs to the runtime. The generated code is unchanged.
Compiled templates used it for t-memo, which was removed in Owl 3: the compiler no longer emits it.
mcm-odoo
force-pushed
the
master-template-contract-mcm
branch
from
November 27, 2026 12:11
0d8cf0e to
3000cef
Compare
mcm-odoo
marked this pull request as ready for review
November 27, 2026 12:29
ged-odoo
approved these changes
Nov 27, 2026
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.
Depends on #2080: this branch is based on it, so its first commits
belong to that PR. Only the last three commits are part of this one.
This is the second step of the series that clarifies the boundaries between
the packages. These are type changes plus one removal: the generated code and
the runtime behaviour are unchanged.
Type the app carried by scopes (owl-core)
Scopes carry the application they belong to, so that plugins and components can
reach it, e.g. to create new roots. Since the concrete
Applives inowl-runtime, core typed it as
any. Core only reads two things from it: itsplugin manager and its dev mode.
ScopeAppinterface (exported by owl-core) describes them. It is usedby
Scope,PluginManagerand core'suseApp.ComponentNodedeclares itsappas anApp,and runtime's
useApp()still returns anApp.Describe the template contract as types (owl-compiler, owl-runtime)
A compiled template is created with
(app, bdom, helpers)and calls theblockdom functions and helpers it receives. Which functions exist and how they
are called was only an agreement between the code generator and owl-runtime.
Renaming a helper or changing its arguments on one side only broke when a
template using it was rendered.
TemplateBlockDom(thesix blockdom functions) and
TemplateHelpers(every helper, with itssignature).
TemplateFunctionuses them instead ofany.helpersandbdomobjects must satisfy them.Values the generated code only passes along (contexts, nodes, blocks, the app)
stay
any: their shape belongs to the runtime. As a side effect,owl.d.tsnow also exports
TemplateBlockDomandTemplateHelpers, sinceTemplateFunctionreferences them.Remove the unused
shallowEqualtemplate helper (owl-runtime)Compiled templates used it for
t-memo, which was removed in Owl 3, so thecompiler no longer emits it. The public
shallowEqualutility (from owl-core)is unaffected.
Checks
npm run build,npm run build:types,npm test(all packages),npm run test:typesandnpm run check-formattingpass. No snapshot changes.helper with an extra argument, a missing helper and a misspelled helper name
in the code generator each fail type-checking.