Added
-
Added the
slice_to_arrayattribute for imported JS functions, which makes a&[T](orOption<&[T]>) argument arrive on the JS side as a plainArrayrather than a typed array — without changing the Rust-side&[T]signature. Useful when binding JS APIs that takeT[]rather thanTypedArray<T>. For primitive element kinds the wire is the same zero-copy borrow used by plain&[T], with the JS-side shim wrapping the view inArray.from(...)to materialise theArray— no extra allocation. ForString,JsValue, and JS-imported element types the Rust side builds a fresh[u32]index buffer that JS reads and frees, with per-element&T -> JsValue(refcount bump for handle-shaped types). NoT: Clonebound is required. The attribute can be set per-fn (#[wasm_bindgen(slice_to_array)] fn ...) or per-block on anextern "C" { ... }declaration to apply to every imported function in that block.&[ExportedRustStruct]remains unsupported (use ownedVec<T>for that). Has no effect on exported functions; default&[T](typed-array view / memory borrow) and ownedVec<T>semantics are unchanged for callers that didn't opt in. See theslice_to_arrayguide page. #5145 -
Added
js_sys::AggregateErrorbindings (constructor,errorsgetter, andnew_with_message/new_with_optionsoverloads).AggregateErrorrepresents multiple unrelated errors wrapped in a single error, e.g. as thrown byPromise.anywhen all input promises reject, along withjs_sys::ErrorOptions, accepted by built-in error constructors.ErrorOptions::new(cause)constructs an instance pre-populated withcause, andget_cause/set_causeprovide typed access to the property. All standard error constructors that previously took only amessage(EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,WebAssembly.CompileError,WebAssembly.LinkError,WebAssembly.RuntimeError) now expose anew_with_options(message, &ErrorOptions)overload, andErrorgainsnew_with_error_options(message, &ErrorOptions)alongside the existing untypednew_with_options.AggregateError::new_with_optionsalso takes&ErrorOptions. #5139 -
Added inheritance for Rust-exported types: an exported struct may declare
#[wasm_bindgen(extends = Parent)]to inherit from another exported#[wasm_bindgen]struct. The macro injects a hiddenparent: wasm_bindgen::Parent<Parent>field (a refcounted cell around the parent value) and emitsclass Child extends Parentin the generated JS /.d.ts. The child gets anAsRef<Parent<Parent>>impl for the direct parent, and threads per-class pointer slots through the wasm ABI so thatinstanceof Parentis true and parent methods dispatch soundly via the JS prototype chain. From inside child methods, parent data is reached viaself.parent.borrow()/self.parent.borrow_mut(). See the newextendsguide page. #5120 -
Added
js_sys::FinalizationRegistrybindings (constructor,register,register_with_token, andunregister). The cleanup callback parameter is typed as&Function<fn(JsValue) -> Undefined>, so closures created viaClosure::newcan be passed usingFunction::from_closure(for owned closures retained by JS) orFunction::closure_ref(for borrowed scoped closures). Pairs with the existingjs_sys::WeakRefbindings. #5140 -
Added support for well-known symbols in
js_name,getter, andsettervia the explicit bracket-string form"[Symbol.<name>]". This works for imported and exported methods, fields, getters, and setters. For example,#[wasm_bindgen(js_name = "[Symbol.iterator]")]on an exported method generates[Symbol.iterator]() { ... }on the generated JS class, and the same syntax works forgetter/setterand for imported items. #4230 -
Added level 2 bindings for
ViewTransitiontoweb-sys. #5138 -
Add support for dynamic unions: a
#[wasm_bindgen]enum that mixes string-literal variants with single-field tuple variants is now exported as an untagged TypeScript union and dispatched dynamically at the JS↔Rust boundary. The new enum-level#[wasm_bindgen(fallback)]attribute makes the last tuple variant an unconditional catch-all, supporting unions whose trailing variant has no runtime check (e.g., interface-only imports). String enums and dynamic unions now emitexport type(was baretype) so the alias is a named export, and both honour theprivateflag to suppress the keyword. #4734 #2153 #2088
Fixed
-
From<Promise<T>> for JsFuture<T>andIntoFuture for Promise<T>now accept anyT: FromWasmAbi(rather thanT: JsGeneric), letting importedasync fns return dynamic-union enums. -
TryFromJsValuefor C-style enums no longer accepts non-numeric values via JS unary+coercion. Previously callingdyn_into::<MyEnum>()on a string would silently coerce it via+"foo"(yieldingNaN, thenNaN as u32 = 0) and could match a discriminant by accident; the conversion now returnsNonefor any value that is not a JS number. #4734 -
Fix compilation failure with
no_std+release#5134 -
Raw identifiers (
r#name) on enums, enum variants, extern types, statics, andimplblocks no longer leak ther#prefix into generated JS / TS output and shim names. The Rust-side identifier and the JS-side name are now tracked separately for enum variants, and all known identifier fallback paths applyIdent::unraw()so e.g.pub enum r#Enum { r#A }generatesEnum.Ainstead of producing syntactically invalid JS. #4323 -
Using the
-C panic=unwindoption when building for the bundler target would produce invalid JS. #5142
Changed
js_sys::DataViewnow implements thejs_sys::TypedArraytrait. AFIXMEnotes that the trait should be renamed toArrayBufferViewin the next major release to better reflect the WebIDL spec name covering bothDataViewand the typed-array types. #5135