Is it possible to destructure an object? For example:
let person = { "name": "John", "surname": "Smith" }
let { name } = person
The previous code throws the following error:
The record field name can't be found.
Is it possible to destructure an object? For example:
let person = { "name": "John", "surname": "Smith" }
let { name } = person
The previous code throws the following error:
The record field name can't be found.
Hi, it’s not possible to destructure an object.
But it’s possible to destructure a record. And since a record is a shared data type that compiles to JS objects, maybe it makes sense to use a ReScript record (unless something very dynamic happens on the JS side).