Severity: error | Blocks morph build: yes
Status: documented rule —
morph checkdoes not report this code yet. The underlying problem still breaks your build or your UI; the cause and fix below apply when you hit it.
A JavaScript expression or statement in your component logic, handler, effect, or helper cannot be translated to C++:
error : mx-transpile : Cannot translate to C++: `?.` optional chaining in `user?.name`
hint: Use an explicit check: `user ? user.name : ""`
Learn more: https://morph.levizr.com/docs/errors/mx-transpileThe flagged location may be a JSX expression, an event/effect body, a component const, an inner function, a global, or a top-level function — anything the translator must emit as native code.
Morph has no JavaScript engine in the binary: your logic is transpiled to C++ ahead of time (see how JavaScript compiles and intent-based codegen). Every construct must have a native lowering. When none exists, generating something would mean generating wrong code — so the compiler stops and tells you exactly which expression, and usually the rewrite. Coverage grows over time (see translator coverage plans); the specific unsupported-feature codes below are sub-cases of this general rule.
// ❌ Depends on the case: optional chaining, object spread, etc.
export default function App() {
const user = { name: "Ada" };
return <div>{user?.name}</div>;
}Rewrite with supported constructs. Common rewrites:
| Instead of | Write |
|---|---|
user?.name |
user ? user.name : "" |
{...obj, x: 1} |
explicit object construction |
arr?.map(...) |
guard then map |
| unsupported method | equivalent supported method or helper |
// ✅ Explicit check instead of `?.`
export default function App() {
const user = { name: "Ada" };
return <div>{user ? user.name : ""}</div>;
}Steps:
mx-js-op, mx-js-syntax,
mx-js-method, ...), open that page for the precise fix..cpp native function and import it
(see native C++).morph check.Do not disable this rule. Untranslatable code has no native representation.