Skip to content

Conversation

@zardoy
Copy link
Contributor

@zardoy zardoy commented Feb 19, 2023

This case is supported:

let x

if (x === undefined || x === null) x = 1
if (!x) x = "2"
if (x) x = true

So why don't support this:

let x

x ??= 1
x ||= "2"
x &&= true

TypeScript docs

Real world pattern:

let x

function workWithX() {
  // init lazily
  x ??= ...
}

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Feb 19, 2023
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@sandersn sandersn assigned iisaduan and sandersn and unassigned iisaduan and sandersn Feb 28, 2023
@sandersn
Copy link
Member

That makes sense to me.
Next time please open a bug for your idea first, though.

@iisaduan iisaduan merged commit a97ba98 into microsoft:main Apr 10, 2023
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants