Severity: error | Blocks morph build: yes
Status: reported by
morph check. The gate exits non-zero, so a cleanmorph checkmeans no rejected syntax remains. Only probe-verified breakage is rejected — common JS spellings that lower correctly stay allowed.
Your code uses a syntax construct the translator cannot represent in C++. The current set is:
yieldwith statementbreak / continueimport.meta and dynamic import()namespace blocksenum declarations/ab+c/)...args)f(...args), new C(...args); the
variadic array helpers push/unshift/splice/concat and
Math.min/Math.max are supported)import * as ns namespace importsdouble,
template, delete, …)const/let initializer
(module-scope initializers lower to a named class; function-local and
every other position are rejected){ handler: save } — JsObject
fields cannot store closures)for...in with a destructuring binding (bind the key with a plain name,
then destructure the value inside the loop body).then / .catch chains outside the supported statement-level
fetch(...).then(...).catch(...) form inside an async function (one
.then and/or one .catch, non-async callback with at most one plain
parameter; use async/await and try/catch otherwise)Promise.resolve(fetch(...)), nested await, promise-valued identifiers
inside combinators, nested combinators, new Promise(...) inside
combinators, fetch inside Promise.race/Promise.any, empty
race/any arrays, spread/elided elements, return Promise.resolve()
without a value, Promise.resolve(...) as the expression body of a
fire-and-forget (Task/void) function, and Promise.all /
allSettled / race / any outside the whole await of a const/let
declaration or an expression statement inside an async functionJSON.parse reviver and JSON.stringify replacer/space argumentslet/const reads before the declaration line (the temporal dead zone),
including self-referential initializers such as let x = xvar declarations (var { a } = obj) and late var
initializers that cannot start as undefined (arrow, function, class,
or new expressions)error : mx-js-syntax : `enum` declaration cannot be translated to C++
hint: Use a plain object const with string/number literals
Learn more: https://morph.levizr.com/docs/errors/mx-js-syntaxThese lower correctly and are not errors: optional chaining ?.,
nullish coalescing ??, for...in over objects and arrays / for...of, new.target
in constructors and functions, switch on
strings, numbers, and mixed case values (JavaScript === semantics with
fallthrough), array spread, object spread and computed keys, getters and setters,
plain-TS destructuring declarations, destructuring assignment, for...of
declaration and assignment patterns, destructuring at the top of a
component body, var hoisting with undefined initialization (including
block, loop, and component-body declarations), class declarations / new, module-scope class expressions
directly assigned to a const/let, type-only imports and exports,
default and optional parameters, arrow/function consts, data-only
object-literal consts, statement-level fetch(...).then(...).catch(...)
chains inside async functions, trailing timer arguments on inline arrow
callbacks, the supported Promise static shapes (Promise.resolve(value),
awaited Promise.all/allSettled over array literals, and
Promise.race/any over already-settled values), and JSX list
expressions. for...in destructuring
is rejected; bind the key with a plain name and destructure inside the
loop body. Every JavaScript language and standard-library gap is committed
for implementation in the
coverage plan; browser globals remain
out of scope.
Each rejected construct needs hidden runtime machinery Morph omits on
purpose: generators need resumable frames; with needs dynamic scope;
labeled jumps have no C++ equivalent; import.meta / dynamic import()
need a module loader; namespaces
and decorators vanish in translation; enums and regex literals have no
lowering yet. .then/.catch outside the supported statement-level
fetch chain needs a general promise-chain runtime, JSON extra arguments
would be silently dropped, and timer arguments need an inline arrow
callback whose parameters can receive them. Supporting any of them
approximately would change program meaning — so each is rejected with an
explicit rewrite. See
translator coverage for what is planned.
// ❌ TypeScript enum — mx-js-syntax
export default function App() {
enum Color { Red, Green }
return <div>{Color.Red}</div>;
}// ❌ Closure stored in an object — mx-js-syntax
export default function App() {
const save = () => console.log("saved");
const handlers = { save };
return <button onClick={handlers.save}>Save</button>;
}// ❌ Namespace import — mx-js-syntax
import * as lib from "./lib.ts";
export default function App() {
return <div>{lib.token}</div>;
}// ❌ C++ keyword as a binding name — mx-js-syntax
export default function App() {
const double = 2;
return <div>{double}</div>;
}// ❌ Promise chain used as a value — mx-js-syntax
async function load() {
const pending = fetch("https://api.example.com/data").then((r) => r.text())
console.log(pending)
}// ❌ Promise combinator outside a supported await position — mx-js-syntax
async function load() {
const pending = Promise.all([1, 2])
console.log(pending)
}// ❌ Fire-and-forget arrow returning a promise value — mx-js-syntax
const load = async () => Promise.resolve(1)| Instead of | Write |
|---|---|
enum Color { Red } |
const Color = { Red: "Red" } |
/ab+c/ |
plain string checks or a .cpp helper |
import * as lib |
import { token, greet } from "./lib.ts" |
...args |
an explicit array parameter |
f(...args) / new C(...args) |
pass each argument explicitly, or use push/unshift/splice/concat and Math.min/Math.max for variadic arrays |
const C = class { … } |
a module-scope direct const/let initializer (supported), or a class declaration |
{ handler: fn } |
keep fn as its own const and call it directly |
for (const [k] in object) |
for (const k in object) { … } — bind the key plainly; destructure the value inside the body |
fetch(...).then(...) as a value |
a statement-level chain inside an async function (supported), or const r = await fetch(...) inside try/catch |
Promise.all([...]) as a value |
const xs = await Promise.all([...]) inside an async function (supported), with fetch(...), Promise.resolve(value), or plain elements |
async () => Promise.resolve(value) |
async (): Promise<T> => Promise.resolve(value), or async function f(): Promise<T> { return Promise.resolve(value) } |
JSON.parse(text, reviver) |
parse once, then transform the value |
JSON.stringify(value, replacer, 2) |
stringify the value, then format the result |
setTimeout(handler, ms, a, b) (identifier callback) |
setTimeout((a, b) => handler(a, b), ms, a, b) |
generator / yield |
a state machine with morphState |
with (o) { ... } |
explicit o. qualification |
labeled break/continue |
a flag variable or early return |
import.meta / import() |
static imports and constants |
namespace N { ... } |
exported functions and constants |
a C++ keyword binding or member (double, template, delete, …) |
rename the binding/field/method |
| decorators | inline the decorator's effect |
// ✅ Object const instead of an enum
const Color = { Red: "red", Green: "green" };
export default function App() {
return <div>{Color.Red}</div>;
}Steps:
.cpp
(see native C++).morph check; only a clean check should be followed by a build.Do not disable this rule. These constructs have no native representation.