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

boolean | null auto translates to false ? #1720

Open
JimmyBjorklund opened this issue Nov 18, 2024 · 1 comment
Open

boolean | null auto translates to false ? #1720

JimmyBjorklund opened this issue Nov 18, 2024 · 1 comment

Comments

@JimmyBjorklund
Copy link

Hi
Have an update request that looks like this

interface UpdateRequest {
  u: boolean | null
}

@Put("g/{id}")
async updateU(id: string, @Body() body: UpdateRequest ): Promise<void> {
   console.log("update", body);
}

When trying to pass null to the variable u it auto translates to false instead of null that one would expect.
Is this expected?
/Jimmy

@JimmyBjorklund
Copy link
Author

Found another strang thing if i set
u: "null" | boolean;
Then passing both null and "null" seems to work, this seams wrong if i set a string "null" then null should not work ?

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

No branches or pull requests

1 participant