-
Notifications
You must be signed in to change notification settings - Fork 29
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
Stricter checks in LegacyColor
constructor
#349
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
lib/src/legacy/value/color.ts
Outdated
@@ -22,7 +22,7 @@ export class LegacyColor extends LegacyValueBase<SassColor> { | |||
} | |||
|
|||
let red: number; | |||
if (!green || !blue) { | |||
if (green == undefined || blue == undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use triple equal instead of double equal if you are comparing with undefined
, or otherwise linter will complain.
if (green == undefined || blue == undefined) { | |
if (green === undefined || blue === undefined) { |
If you want to check both undefined and null, you have to do them separately, due to how linter is setup here. You can run linter with npm run check
locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, just pushed a change to explicitly check for both undefined
and null
lib/src/legacy/value/color.ts
Outdated
function isUndefinedOrNull<A>(a: A): boolean { | ||
return a === undefined || a === null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document this, and put it in utils.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out there was already an isNullOrUndefined
function in lib/src/utils.ts
so I'm using that now
lib/src/legacy/value/color.ts
Outdated
@@ -5,6 +5,10 @@ | |||
import {SassColor} from '../../value/color'; | |||
import {LegacyValueBase} from './base'; | |||
|
|||
function isUndefinedOrNull<A>(a: A): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function isUndefinedOrNull<A>(a: A): boolean { | |
function isUndefinedOrNull(a: unknown): boolean { |
Fixes #348
Rather than just checking if
green
orblue
are falsy, the code now checks if they'reundefined
ornull
.