decodeUnknownPromise returns a Promise instead of throwing or returning Exit / Option.
- If decoding succeeds, the Promise resolves with the decoded value.
- If decoding fails, the Promise rejects with a
SchemaIssue.Issue.
import { Schema, SchemaIssue } from "effect";
const schema = Schema.Struct({ name: Schema.String, age: Schema.Number,});
const decode = Schema.decodeUnknownPromise(schema);
// Happy pathconst decoded = await decode({ name: "Alice", age: 30 });console.log("Decoded Value:", decoded);
// Error pathtry { await decode({ name: 42, age: "30" }, { errors: "all" });} catch (issue) { if (SchemaIssue.isIssue(issue)) { console.log("Error Message:", String(issue)); console.log("Issue Tree:", issue); }}Use decodeUnknownPromise when you want schema decoding to fit into async/await and Promise-based
code.