Skip to content

Commit

Permalink
fix: reverse warning type check
Browse files Browse the repository at this point in the history
  • Loading branch information
etienneburdet committed Dec 6, 2024
1 parent 1bebad4 commit 259e9cd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@
export let debugWarnings = false;
$: format = (v: unknown) => {
if (typeof v !== 'boolean') {
if (debugWarnings) {
warn(v, 'boolean');
}
}
// Currently we return the raw value until we have alternative renders
if (display) {
if (typeof v === 'boolean' && display) {
return display(v as boolean);
}
if (debugWarnings) {
warn(v, 'boolean');
}
return v;
// Currently we return the raw value until we have alternative renders
};
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
export let debugWarnings = false;
$: format = (v: unknown) => {
if (typeof v !== 'string') {
if (debugWarnings) {
warn(v, 'text');
}
}
if (display) {
if (typeof v === 'string' && display) {
return display(v as string);
}
if (debugWarnings) {
warn(v, 'text');
}
return v;
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
export let debugWarnings = false;
$: format = (v: number) => {
if (!Number.isFinite(v)) {
if (Number.isFinite(v)) {
if (debugWarnings) {
warn(v, 'number');
}
return v;
}
const intlValue = new Intl.NumberFormat(locale, intl).format(v);
if (display) {
return display(intlValue);
const intlValue = new Intl.NumberFormat(locale, intl).format(v);
if (display) {
return display(intlValue);
}
return intlValue;
}
return intlValue;
return v;
};
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
export let debugWarnings = false;
$: format = (v: unknown) => {
if (typeof v !== 'string') {
if (debugWarnings) {
warn(v, 'text');
}
}
if (display) {
if (typeof v === 'string' && display) {
return display(v as string);
}
if (debugWarnings) {
warn(v, 'text');
}
return v;
};
</script>
Expand Down

0 comments on commit 259e9cd

Please sign in to comment.