Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shape with pointer of false produces type suggesting the pointer is returned #1037

Open
CarsonF opened this issue Jun 7, 2024 · 2 comments
Labels

Comments

@CarsonF
Copy link
Collaborator

CarsonF commented Jun 7, 2024

e.select(e.X, {
  foo: false
})

Runtime omits foo from EdgeQL, but TS types it as never.
This allows it to be compatible, somehow, with a type expecting that property.

class X {
  foo: string;
}
const withX = (x: X) => {...};

const result = await e.select(e.X, {
  foo: false
}).run();

// This is fine even though `foo` is required, and not in the DB result.
withX(result[0]);

I think the type should be changed to undefined, or maybe unknown instead?

@scotttrinh
Copy link
Collaborator

Yeah, great point. "never is assignable to anything"

Options:

  1. Remove this key from the resulting object.
  2. Assign undefined to this key in the resulting object and make the type reflect that.
  3. Use unknown and... not sure what the runtime should be here since unknown doesn't really imply anything to me about this key in the resulting object. Other than maybe that it exists?

I think the first option makes the most sense since I think that's kind of how you would instinctively use false: as a way to remove a property (for instance after a ["*"] splat spread).

@scotttrinh scotttrinh added the bug label Jun 10, 2024
@CarsonF
Copy link
Collaborator Author

CarsonF commented Jun 10, 2024

Could we change the arg shape to reject false?

| true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants