Skip to content

"Never nullish" checks miss "never nullish" through pareansΒ #62787

@jakebailey

Description

@jakebailey

πŸ”Ž Search Terms

never nullish parenthesis

πŸ•— Version & Regression Information

  • This changed between versions 5.8 and 5.9

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAHgLhgbxgTydATgSzAcxgB8YBXMAEwFMAzPKimAX2LMtvsYF43q6wGMAIYRhYNAG4AsAChZs0JFg0QIGDzgB+AHRoYmzTAAGqgA4Qj+wwCJr0mYugwARkKzqYACi26rxsxYAlH629grgECAANlTaUSD4nioggfaO0bHxia5YqUA

πŸ’» Code

const x: { y: string | undefined } | undefined = undefined as any;


const foo = x?.y ?? `oops` ?? "";
const bar = (x?.y ?? `oops`) ?? "";

console.log(foo);
console.log(bar);

πŸ™ Actual behavior

Error on foo's expression, no error on bar's.

πŸ™‚ Expected behavior

Error on both; both expressions are guaranteed to be "oops".

Additional information about the issue

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions