Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

strict-boolean-expressions: new option allow-boolean-or-undefined #2820

Merged
merged 3 commits into from May 24, 2017
Merged

strict-boolean-expressions: new option allow-boolean-or-undefined #2820

merged 3 commits into from May 24, 2017

Conversation

ajafff
Copy link
Contributor

@ajafff ajafff commented May 24, 2017

PR checklist

  • Addresses an existing issue: #0000
  • New feature, bugfix, or enhancement
    • Includes tests
  • Documentation update

Overview of change:

I find it weird to compare for strict equality on unions of boolean and undefined. Consider the following function:

function foo(bar?: boolean) {
    if (bar) // not allowed by default
       // do stuff
}

allow-undefined-union would allow too much, because it also allows for example ts.Node | undefined.

It's already awkward to use ts.NodeArray#hasTrailingComma === true. With my recent changes to typescripts typings (microsoft/TypeScript#15887, microsoft/TypeScript#15903), that will hit us with the next version of typescript, this pattern will occur in many more places (e.g. ts.forEachChild).
That's why I added this new option allow-boolean-or-undefined.

Is there anything you'd like reviewers to focus on?

CHANGELOG.md entry:

[new-rule-options] strict-boolean-expressions adds allow-boolean-or-undefined

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

Successfully merging this pull request may close these issues.

None yet

2 participants