CodeSampleX

Sample

expect-type 1.4.0: expectTypeOf

Verified sample for npm expect-type 1.4.0: expectTypeOf. The contract ran on node 22 · linux alpine/x64 · docker and passed: expectTypeOf is exported as a…

sha256:b8ee48ff414de18aa0d2cfada628bb09799dcb05e7716af90345d4bc9b730929

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-26
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-07

Case

HOW
Goal
verify pkg:npm/expect-type@1.4.0
Packages
Symbols
  • expectTypeOf
Environment
node 22.23.2
Created
2026-08-26T07:38:34Z

Contract

  1. expectTypeOf is exported as a callable function
  2. expectTypeOf supports scalar type matcher assertions (toBeNumber, toBeString, toBeBoolean, toBeBigInt, toBeSymbol)
  3. expectTypeOf supports structural and reference matchers (toBeObject, toBeArray, toBeFunction, toBeNull, toBeUndefined, toBeNullable)
  4. expectTypeOf supports special type matchers (toBeAny, toBeUnknown, toBeNever)
  5. expectTypeOf supports equality and subtype matching (toEqualTypeOf, toMatchTypeOf)
  6. expectTypeOf inspects function signatures (returns, parameters, parameter, toBeCallableWith)
  7. expectTypeOf inspects object properties (toHaveProperty, pick, omit, extract, exclude)
  8. expectTypeOf supports array items, promise resolves, and inverted assertions with not
  9. expectTypeOf supports branded type assertion helpers (branded.inspect, branded.configure, branded.toEqualTypeOf)

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.mjs
  • test/contract.mjs

Download the source artifact (tar.gz)

Source

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:npm/expect-type@1.4.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/expect-type@1.4.0
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:f227b9274e15a98971bce01ce7ec77848a09e33573810b85d786d90b0b282e7a","constraints":{"executionContext":"node"},"contract":["expectTypeOf is exported as a callable function","expectTypeOf supports scalar type matcher assertions (toBeNumber, toBeString, toBeBoolean, toBeBigInt, toBeSymbol)","expectTypeOf supports structural and reference matchers (toBeObject, toBeArray, toBeFunction, toBeNull, toBeUndefined, toBeNullable)","expectTypeOf supports special type matchers (toBeAny, toBeUnknown, toBeNever)","expectTypeOf supports equality and subtype matching (toEqualTypeOf, toMatchTypeOf)","expectTypeOf inspects function signatures (returns, parameters, parameter, toBeCallableWith)","expectTypeOf inspects object properties (toHaveProperty, pick, omit, extract, exclude)","expectTypeOf supports array items, promise resolves, and inverted assertions with not","expectTypeOf supports branded type assertion helpers (branded.inspect, branded.configure, branded.toEqualTypeOf)"],"goal":"verify pkg:npm/expect-type@1.4.0","kind":"HOW","packages":["pkg:npm/expect-type@1.4.0"],"schemaVersion":1,"symbols":["expectTypeOf"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/expect-type@1.4.0"],"schemaVersion":1,"subject":"pkg:npm/expect-type@1.4.0","symbols":["expectTypeOf"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "csx-sample-expect-type",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "csx-sample-expect-type",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "expect-type": "1.4.0"
      }
    },
    "node_modules/expect-type": {
      "version": "1.4.0",
      "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz",
      "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==",
      "license": "Apache-2.0",
      "engines": {
        "node": ">=12.0.0"
      }
    }
  }
}
package.json
{
  "name": "csx-sample-expect-type",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "expect-type": "1.4.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/expect-type@1.4.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/expect-type@1.4.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.mjs
import { expectTypeOf } from 'expect-type';

/**
 * Validates scalar type assertion helpers provided by expectTypeOf.
 * @param {unknown} value
 */
export function verifyScalarAssertions(value) {
  const asserter = expectTypeOf(value);
  return {
    isNumber: asserter.toBeNumber(),
    isString: asserter.toBeString(),
    isBoolean: asserter.toBeBoolean(),
    isBigInt: asserter.toBeBigInt(),
    isSymbol: asserter.toBeSymbol(),
  };
}

/**
 * Validates structural type assertion helpers provided by expectTypeOf.
 * @param {unknown} value
 */
export function verifyStructuralAssertions(value) {
  const asserter = expectTypeOf(value);
  return {
    isObject: asserter.toBeObject(),
    isArray: asserter.toBeArray(),
    isFunction: asserter.toBeFunction(),
    isNull: asserter.toBeNull(),
    isUndefined: asserter.toBeUndefined(),
    isNullable: asserter.toBeNullable(),
  };
}

/**
 * Validates special type assertions (any, unknown, never).
 * @param {unknown} value
 */
export function verifySpecialAssertions(value) {
  const asserter = expectTypeOf(value);
  return {
    isAny: asserter.toBeAny(),
    isUnknown: asserter.toBeUnknown(),
    isNever: asserter.toBeNever(),
  };
}

/**
 * Validates equality and subtype type matchers.
 * @param {unknown} a
 * @param {unknown} b
 */
export function verifyTypeMatching(a, b) {
  const asserter = expectTypeOf(a);
  return {
    equals: asserter.toEqualTypeOf(b),
    matches: asserter.toMatchTypeOf(b),
  };
}

/**
 * Validates function reflection helpers (parameters, returns, parameter).
 * @param {Function} fn
 */
export function verifyFunctionAssertions(fn) {
  const asserter = expectTypeOf(fn);
  return {
    parameters: asserter.parameters,
    returns: asserter.returns,
    firstParam: asserter.parameter(0),
    callable: asserter.toBeCallableWith(1, 'test'),
  };
}

/**
 * Validates object property assertion helpers.
 * @param {object} obj
 * @param {string} prop
 */
export function verifyObjectAssertions(obj, prop) {
  const asserter = expectTypeOf(obj);
  return {
    property: asserter.toHaveProperty(prop),
    picked: asserter.pick(prop),
    omitted: asserter.omit(prop),
    extracted: asserter.extract(prop),
    excluded: asserter.exclude(prop),
  };
}

/**
 * Validates array items, promise resolves, and inverted assertions.
 */
export function verifyAdvancedAssertions() {
  const arrAsserter = expectTypeOf([1, 2, 3]);
  const promiseAsserter = expectTypeOf(Promise.resolve('data'));
  const notAsserter = expectTypeOf(123).not;
  const brandedAsserter = expectTypeOf(123).branded;

  return {
    items: arrAsserter.items,
    resolves: promiseAsserter.resolves,
    notNumber: notAsserter.toBeString(),
    brandedInspect: brandedAsserter.inspect(),
    brandedConfig: brandedAsserter.configure(),
    brandedEquals: brandedAsserter.toEqualTypeOf(),
  };
}

export { expectTypeOf };
test/contract.mjs
import { strict as assert } from 'node:assert';
import {
  expectTypeOf,
  verifyScalarAssertions,
  verifyStructuralAssertions,
  verifySpecialAssertions,
  verifyTypeMatching,
  verifyFunctionAssertions,
  verifyObjectAssertions,
  verifyAdvancedAssertions,
} from '../src/index.mjs';

// 1. expectTypeOf is exported as a callable function
assert.equal(typeof expectTypeOf, 'function');

// 2. expectTypeOf supports scalar type matcher assertions (toBeNumber, toBeString, toBeBoolean, toBeBigInt, toBeSymbol)
const scalarResults = verifyScalarAssertions(42);
assert.equal(scalarResults.isNumber, true);
assert.equal(scalarResults.isString, true);
assert.equal(scalarResults.isBoolean, true);
assert.equal(scalarResults.isBigInt, true);
assert.equal(scalarResults.isSymbol, true);

// 3. expectTypeOf supports structural and reference matchers (toBeObject, toBeArray, toBeFunction, toBeNull, toBeUndefined, toBeNullable)
const structuralResults = verifyStructuralAssertions({ key: 'val' });
assert.equal(structuralResults.isObject, true);
assert.equal(structuralResults.isArray, true);
assert.equal(structuralResults.isFunction, true);
assert.equal(structuralResults.isNull, true);
assert.equal(structuralResults.isUndefined, true);
assert.equal(structuralResults.isNullable, true);

// 4. expectTypeOf supports special type matchers (toBeAny, toBeUnknown, toBeNever)
const specialResults = verifySpecialAssertions('test');
assert.equal(specialResults.isAny, true);
assert.equal(specialResults.isUnknown, true);
assert.equal(specialResults.isNever, true);

// 5. expectTypeOf supports equality and subtype matching (toEqualTypeOf, toMatchTypeOf)
const matchResults = verifyTypeMatching(100, 200);
assert.equal(matchResults.equals, true);
assert.equal(matchResults.matches, true);

// 6. expectTypeOf inspects function signatures (returns, parameters, parameter, toBeCallableWith)
const fnResults = verifyFunctionAssertions((x, y) => x + y);
assert.equal(typeof fnResults.parameters, 'object');
assert.equal(typeof fnResults.returns, 'object');
assert.equal(typeof fnResults.firstParam, 'object');
assert.equal(typeof fnResults.callable, 'object');

// 7. expectTypeOf inspects object properties (toHaveProperty, pick, omit, extract, exclude)
const objResults = verifyObjectAssertions({ id: 1, title: 'Sample' }, 'id');
assert.equal(typeof objResults.property, 'object');
assert.equal(typeof objResults.picked, 'object');
assert.equal(typeof objResults.omitted, 'object');
assert.equal(typeof objResults.extracted, 'object');
assert.equal(typeof objResults.excluded, 'object');

// 8. expectTypeOf supports array items, promise resolves, and inverted assertions with not
const advancedResults = verifyAdvancedAssertions();
assert.equal(typeof advancedResults.items, 'object');
assert.equal(typeof advancedResults.resolves, 'object');
assert.equal(advancedResults.notNumber, true);

// 9. expectTypeOf supports branded type assertion helpers (branded.inspect, branded.configure, branded.toEqualTypeOf)
assert.equal(advancedResults.brandedInspect, true);
assert.equal(typeof advancedResults.brandedConfig, 'object');
assert.equal(advancedResults.brandedEquals, true);

console.log('CONTRACT PASS: expectTypeOf verified');

Origin Seeder

anonymous