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

Improve types and remove almost all any types #373

Merged
merged 2 commits into from
Sep 20, 2021
Merged

Conversation

rkuykendall
Copy link
Contributor

@rkuykendall rkuykendall commented Sep 20, 2021

I was annoyed that insertIf wasn't preserving types.

Failing "tests" are just Coveralls downtime

image

image

@@ -125,7 +125,7 @@ export function getNameOrDefault(obj?: unknown, { field = 'name', defaultValue =
return defaultValue;
}

export function getOrDefault(value?: any) {
export function getOrDefault(value?: unknown) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just read a bit about unknown types. They are rly nice!

export function getPercentValue(value?: null | string): string {
if (typeof value === 'undefined' || value === null || value === '') {
function _isDecimalValue(value: unknown): value is Decimal.Value {
return (isString(value) && value !== '') || isNumber(value) || Decimal.isDecimal(value);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little confused here, how does checking if it is a string and not empty suffice for it being a Decimal.Value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see here the definition of Decimal.Value is string or number or Decimal

image

@rkuykendall rkuykendall merged commit ce5fb78 into master Sep 20, 2021
@rkuykendall rkuykendall deleted the better-types branch September 20, 2021 20:35
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

Successfully merging this pull request may close these issues.

2 participants