Severity: error | Blocks morph build: yes
Status: reported by
morph check, but only for provably-typed receivers (literals and state with a pinned type). Anything unprovable stays quiet — an unprovable receiver is never an error.
You call a method the runtime types do not implement, on a value whose type the checker can prove (a literal, or state with a type argument or literal initializer):
error : mx-js-method : Method `.toSorted()` is not implemented for arrays
hint: Check the runtime type docs for supported methods, or use a `.cpp` helper
Learn more: https://morph.levizr.com/docs/errors/mx-js-methodSupported today: strings (toUpperCase, toLowerCase, charAt,
indexOf, substring, slice, trim, replace, split, includes,
startsWith, padStart, repeat, match, … — the full translator
table), arrays (push, pop, join, slice, concat, map, filter,
forEach, reduce, find, findIndex, some, every, sort,
splice, shift, unshift, fill, flat, flatMap, …), objects
(has, keys, get), numbers/booleans (toString). Everything else on a
proven receiver errors; unprovable receivers (params, call results, any)
stay quiet.
String, array, and object operations in Morph lower to morph::str helpers
and container methods on the native types. Coverage is broad but not total
(see translator coverage): exotic or highly
dynamic methods have no helper to call. Emitting a guessed equivalent would
change string semantics silently — the worst kind of bug in UI text — so the
call is rejected with the exact method named.
import { morphState } from 'morph';
export default function App() {
const [items, setItems] = morphState([3, 1, 2]);
// ❌ `.toSorted()` has no native lowering — mx-js-method
return <div>{items.toSorted().join(",")}</div>;
}// ✅ Native helper for the missing method
import { shout } from './helpers.cpp';
import { morphState } from 'morph';
export default function App() {
const [name, setName] = morphState("ada");
return <div>{shout(name)}</div>;
}Steps:
.cpp helper.morph check.Do not disable this rule. Unimplemented methods have no native code to call.