Skip to content

feat(nanoviews): rename the truthy and falsy narrowing types - #211

Merged
dangreen merged 1 commit into
mainfrom
feat/nanoviews-narrowing-types
Aug 24, 2026
Merged

feat(nanoviews): rename the truthy and falsy narrowing types#211
dangreen merged 1 commit into
mainfrom
feat/nanoviews-narrowing-types

Conversation

@dangreen

Copy link
Copy Markdown
Member

Four types in nanoviews narrow a value by whether it is truthy, and if_ hands two of them to its branches:

export function if_<T>($value: T) {
  return (
    then_: (value: TruthySignalish<T>) => Child,
    else_?: (value: FalsySignalish<T>) => Child
  ) => 
}

Their names were wrong in two different ways.

TruthyValueOrSignal and FalsyValueOrSignal were named after ValueOrAccessor, which became Signalish in #210 — so they were left pointing at a union that no longer exists.

TruthySignal and FalsySignal were never about signals: like their siblings they test Accessor, and answer never for anything that is not one.

-export type TruthySignal<T> = T extends Accessor<infer U>
+export type TruthyAccessor<T> = T extends Accessor<infer U>
   ? U extends FalsyValue
     ? never
     : T
   : never

-export type TruthyValueOrSignal<T> = T extends Accessor<infer U>
+export type TruthySignalish<T> = T extends Accessor<infer U>
   ? U extends FalsyValue
     ? never
     : T
   : T extends FalsyValue
     ? never
     : T

The suffix now carries the only thing that separates the two pairs: -Accessor requires an accessor and gives never to anything else, -Signalish also takes a plain value. That is the same opposition AccessorValue and SignalishValue already carry.

No aliases: the package is not published yet. TruthyAccessor and FalsyAccessor have no consumer anywhere in the monorepo — they could be deleted instead of renamed, which is a separate call to make.

Types only: every bundle is byte-identical and no pin moves. 114 tests, lint and tsc --noEmit green.

`TruthyValueOrSignal` and `FalsyValueOrSignal` are named after a union that no longer exists, and `TruthySignal`/`FalsySignal` were never about signals at all: all four test `Accessor`.

The suffix now says which input each one takes. `TruthyAccessor` and `FalsyAccessor` narrow something that has to be an accessor and answer `never` to anything else; `TruthySignalish` and `FalsySignalish` narrow a value that may not be one - the same opposition `AccessorValue` and `SignalishValue` carry.
@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.33%. Comparing base (c42723a) to head (ae8ecd9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #211   +/-   ##
=======================================
  Coverage   85.33%   85.33%           
=======================================
  Files         139      139           
  Lines        3143     3143           
  Branches      591      591           
=======================================
  Hits         2682     2682           
  Misses        332      332           
  Partials      129      129           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dangreen
dangreen merged commit 577c49d into main Aug 24, 2026
10 checks passed
@dangreen
dangreen deleted the feat/nanoviews-narrowing-types branch August 24, 2026 20:23
@github-actions github-actions Bot mentioned this pull request Aug 24, 2026
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.

1 participant