npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@actualwave/type-checker-levels-storage

v0.0.5

Published

Type information storage

Downloads

335

Readme

@actualwave/type-checker-levels-storage

Type information storage for @actualwave/type-checkers. Stores the set of types ever observed for each property and controls how much type history to retain via reporting levels.

Installation

npm install @actualwave/type-checker-levels-storage

Reporting levels

A reporting level determines what type information is stored for a property.

| Constant | Value | Description | |---|---|---| | REPORT_ALL_ASSIGNED_TYPES | 'all' | Accumulate every distinct type ever assigned — each new type is reported once | | REPORT_FIRST_TYPE_ONLY | 'first' | Record only the first observed type — every subsequent mismatch is reported | | REPORT_NEVER | 'never' | Do not store any type information |

The global default is REPORT_FIRST_TYPE_ONLY.

Usage

Creating a storage

import { createTypesStorage } from '@actualwave/type-checker-levels-storage';

const storage = createTypesStorage();

Adding type observations

import {
  createTypesStorage,
  REPORT_ALL_ASSIGNED_TYPES,
  REPORT_FIRST_TYPE_ONLY,
} from '@actualwave/type-checker-levels-storage';

const storage = createTypesStorage<string, string>();

storage.add('count', 'number', REPORT_ALL_ASSIGNED_TYPES);
storage.add('count', 'string', REPORT_ALL_ASSIGNED_TYPES); // second type stored too

storage.add('label', 'string', REPORT_FIRST_TYPE_ONLY);
storage.add('label', 'number', REPORT_FIRST_TYPE_ONLY);    // ignored — first type wins

Checking stored types

storage.has('count');        // true
storage.get('count');        // Set { 'number', 'string' }
storage.has('unknown');      // false

Per-target reporting levels

Set reporting levels on individual objects or per-property:

import {
  setReportingLevel,
  getReportingLevel,
  REPORT_ALL_ASSIGNED_TYPES,
  REPORT_FIRST_TYPE_ONLY,
  REPORT_NEVER,
} from '@actualwave/type-checker-levels-storage';

const obj = { id: 1, label: 'hello', internal: null };

setReportingLevel(obj, REPORT_ALL_ASSIGNED_TYPES, {
  label: REPORT_FIRST_TYPE_ONLY, // override for this property
  internal: REPORT_NEVER,        // never track 'internal'
});

getReportingLevel(obj, 'id');       // 'all'
getReportingLevel(obj, 'label');    // 'first'
getReportingLevel(obj, 'internal'); // 'never'

Level resolution priority (highest to lowest):

  1. Per-property level on the instance
  2. Object-level on the instance
  3. Per-property level on the constructor
  4. Object-level on the constructor
  5. Global default

Adding observations via a target object

addFor and setFor automatically resolve the level from the target object:

storage.addFor('label', 'string', obj);  // uses getReportingLevel(obj, 'label')
storage.setFor('label', types, obj);

Global reporting level

import {
  setGlobalReportingLevel,
  getGlobalReportingLevel,
  REPORT_ALL_ASSIGNED_TYPES,
} from '@actualwave/type-checker-levels-storage';

setGlobalReportingLevel(REPORT_ALL_ASSIGNED_TYPES);

Merging storages

Copy all entries from one storage into another with copyTo(). When both storages contain the same key a merge strategy resolves the conflict:

import { createTypesStorage, defaultMergeStrategy } from '@actualwave/type-checker-levels-storage';

sourceStorage.copyTo(targetStorage);

// Custom merge strategy: keep only types present in both sets (intersection)
sourceStorage.copyTo(targetStorage, obj, (key, target, source) => {
  source.forEach((type) => {
    if (!target.has(type)) target.delete(type);
  });
  return target;
});

The defaultMergeStrategy performs a union — all types from the source are added to the target.

API reference

Storage — TypeInfoStorage<K, T>

Created via createTypesStorage<K, T>().

| Method | Description | |---|---| | add(key, type, level?) | Record a type observation; level defaults to REPORT_ALL_ASSIGNED_TYPES | | addFor(key, type, target) | Like add() but resolves the level from target | | set(key, types, level?) | Replace the stored type set for a key | | setFor(key, types, target) | Like set() but resolves the level from target | | has(key) | Returns true if any types are stored for key | | get(key) | Returns the Set of stored types for key | | remove(key) | Delete all type data for key | | clone() | Return a deep copy of the storage | | copyTo(storage, target?, mergeStrategy?) | Merge this storage into storage |

Levels

| Function | Description | |---|---| | setGlobalReportingLevel(level) | Change the global default level | | getGlobalReportingLevel() | Read the global default level | | setReportingLevel(target, level, perPropertyLevels?) | Attach levels to a target object | | getReportingLevel(target, key) | Resolve the effective level for a property |

License

MIT