Default and optional values in records

Are default and/or optional values in records possible? Something like the following:

type optionalAndDefault = {
    field?: string="default"
}

Thanks, really enjoying the Rescript by the way

There is no such thing built-in, but you can have similar behavior using optional arguments, see https://rescript-lang.org/try?code=C4TwDgpgBMULxQN4CgpQB5QFxQJYDtgAaVKEbPQktALwoGdgAnAgc2QF9luAbCWAPYAjAFbwoACgB+6OAGYiUkHABMimnABEACwHbNRCQEoj8AHyJ0REERpdkfWAFdxwkdNkBGQyaA

1 Like