Bug Fixes
-
perry initTypeScript type stubs were broken for non-numeric State (closes #103).types/perry/ui/index.d.ts:Stateis now generic (State<T = number>).State<string[]>([])andState("")from the docs now type-check instead of erroring on the old number-only signature.- Added the
ForEach(count: State<number>, render)export — it was used in the docs todo-app example but missing from the stub. stateBindTextfieldnow takesState<string>to match its purpose.
-
UI docs examples called a
TextField(state, placeholder)form that didn't exist and segfaulted at launch.UiArgKind::Stratcrates/perry-codegen/src/lower_call.rs:2557routes the first arg throughget_raw_string_ptr, so a State handle (i64) reinterpreted as a NaN-boxed string derefs garbage. Rewrote the examples in:docs/src/getting-started/first-app.md— counter + todo appdocs/src/ui/state.md— two-way binding, onChange, complete exampledocs/src/ui/widgets.md—TextField/SecureField/Toggle/Slider/Picker/ Formdocs/src/ui/dialogs.md— the text-editorTextFieldline
to use the actual runtime signatures:
TextField(placeholder, onChange),Slider(min, max, onChange),Picker(onChange)+pickerAddItem, etc..onChangemethod replaced with the free-functionstateOnChange(state, cb).
Verified
5 example binaries built from the corrected docs (counter, todo, controls, form, onchange) pass tsc --noEmit against the regenerated stubs AND compile + launch without crashing via perry src.ts -o bin.
No runtime/codegen change — stubs are embedded into the perry binary via include_str! at compile time and ship to users through perry init / perry types.