Skip to content

Consider disallowing primitive booleans for undefined keys in object shape #1293

@scotttrinh

Description

@scotttrinh

A query like this:

const q = e.select(e.User, () => ({
  name: true,
  birthdaet: true,
}));

Will type-check (and run) successfully since it treats the typo birthdaet as a computed with the value true. While this is a supported use case, it's rarely an intentional one. If you intend to set a computed to the literal true or false value, the safer way is to use e.bool(true) and e.bool(false) instead of relying on the automatic primitive up-casting in this case.

It seems somewhat controversial to make a big breaking change like this when it's hard to tell the intent of the caller, making it hard to find out if you're accidentally relying on this behavior. Maybe we can hide this behind a --future-no-primitive-computeds flag and fail for any computed that uses a primitive? Or special case this as --future-no-boolean-computeds?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions