Beispiel
type-check 0.4.0: parsedTypeCheck
Verifiziertes Beispiel für npm type-check 0.4.0: parsedTypeCheck. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.
sha256:d8fe30f1900b5e2453bbf0113f0c21e1a20d437ae3775b98ca61ca2ebfbcc5a3
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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-05 |
Fall
HOW- Ziel
- verify type-check.parsedTypeCheck in pkg:npm/type-check@0.4.0
- Pakete
- Symbole
-
- type-check.parsedTypeCheck
- Umgebung
- node 22.23.2
- Erstellt
- 2026-09-05T18:15:47Z
Contract
- assert parsedTypeCheck validates primitive types against pre-parsed type AST
- assert parsedTypeCheck validates union types and wildcard expressions
- assert parsedTypeCheck validates homogeneous arrays and fixed-length tuples
- assert parsedTypeCheck validates closed object records, optional fields with Maybe, and open records with ...
- assert parsedTypeCheck evaluates custom types via customTypes option with typeOf and validate
- assert parsedTypeCheck evaluates direct AST structures without parseType
Dateien
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Quelltext
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 type-check.parsedTypeCheck in pkg:npm/type-check@0.4.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/type-check@0.4.0
Demonstrate these symbols/APIs:
- type-check.parsedTypeCheck
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.
{"case":{"caseId":"case:sha256:cc94d29932640d643bbc06a7405e3689c9f71b176430837fdd948a15609271df","contract":["assert parsedTypeCheck validates primitive types against pre-parsed type AST","assert parsedTypeCheck validates union types and wildcard expressions","assert parsedTypeCheck validates homogeneous arrays and fixed-length tuples","assert parsedTypeCheck validates closed object records, optional fields with Maybe, and open records with ...","assert parsedTypeCheck evaluates custom types via customTypes option with typeOf and validate","assert parsedTypeCheck evaluates direct AST structures without parseType"],"goal":"verify type-check.parsedTypeCheck in pkg:npm/type-check@0.4.0","kind":"HOW","packages":["pkg:npm/type-check@0.4.0"],"schemaVersion":1,"symbols":["type-check.parsedTypeCheck"]},"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/type-check@0.4.0"],"schemaVersion":1,"subject":"pkg:npm/type-check@0.4.0","symbols":["type-check.parsedTypeCheck"],"verifierAdapter":"node-typescript@1"}
const { parsedTypeCheck, parseType, typeCheck, VERSION } = require('type-check');
function checkParsedType(parsedType, value, options) {
return parsedTypeCheck(parsedType, value, options);
}
function compileAndCheck(typeStr, value, options) {
const parsed = parseType(typeStr);
return parsedTypeCheck(parsed, value, options);
}
module.exports = {
parsedTypeCheck,
parseType,
typeCheck,
VERSION,
checkParsedType,
compileAndCheck,
};
{
"name": "sample-type-check-parsed-type-check",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-type-check-parsed-type-check",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"type-check": "0.4.0"
}
},
"node_modules/prelude-ls": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
"integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
"license": "MIT",
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
"integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
"license": "MIT",
"dependencies": {
"prelude-ls": "^1.2.1"
},
"engines": {
"node": ">= 0.8.0"
}
}
}
}
{
"name": "sample-type-check-parsed-type-check",
"version": "1.0.0",
"description": "Minimal clean-room sample verifying parsedTypeCheck in type-check",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"type-check": "0.4.0"
}
}
{
"schemaVersion": 1,
"goal": "verify type-check.parsedTypeCheck in pkg:npm/type-check@0.4.0",
"kind": "HOW",
"packages": [
"pkg:npm/type-check@0.4.0"
],
"symbols": [
"type-check.parsedTypeCheck"
]
}
import assert from 'node:assert';
import { parseType, parsedTypeCheck, VERSION } from 'type-check';
import { checkParsedType, compileAndCheck } from '../index.js';
// Verify library version
assert.strictEqual(VERSION, '0.4.0', 'VERSION should match 0.4.0');
// 1. Primitive types validation against pre-parsed type AST
const numAst = parseType('Number');
const strAst = parseType('String');
const boolAst = parseType('Boolean');
const undefAst = parseType('Undefined');
const nullAst = parseType('Null');
assert.strictEqual(parsedTypeCheck(numAst, 42), true, 'Number AST matches integer');
assert.strictEqual(parsedTypeCheck(numAst, 3.14), true, 'Number AST matches float');
assert.strictEqual(parsedTypeCheck(numAst, '42'), false, 'Number AST rejects string');
assert.strictEqual(parsedTypeCheck(strAst, 'hello'), true, 'String AST matches string');
assert.strictEqual(parsedTypeCheck(strAst, 100), false, 'String AST rejects number');
assert.strictEqual(parsedTypeCheck(boolAst, true), true, 'Boolean AST matches boolean');
assert.strictEqual(parsedTypeCheck(boolAst, 'true'), false, 'Boolean AST rejects string');
assert.strictEqual(parsedTypeCheck(undefAst, undefined), true, 'Undefined AST matches undefined');
assert.strictEqual(parsedTypeCheck(undefAst, null), false, 'Undefined AST rejects null');
assert.strictEqual(parsedTypeCheck(nullAst, null), true, 'Null AST matches null');
assert.strictEqual(parsedTypeCheck(nullAst, undefined), false, 'Null AST rejects undefined');
// 2. Union types and wildcard expressions
const unionAst = parseType('Number | String');
assert.strictEqual(parsedTypeCheck(unionAst, 100), true, 'Union AST matches Number');
assert.strictEqual(parsedTypeCheck(unionAst, 'sample'), true, 'Union AST matches String');
assert.strictEqual(parsedTypeCheck(unionAst, false), false, 'Union AST rejects Boolean');
const wildcardAst = parseType('*');
assert.strictEqual(parsedTypeCheck(wildcardAst, { arbitrary: true }), true, 'Wildcard matches object');
assert.strictEqual(parsedTypeCheck(wildcardAst, [1, 2]), true, 'Wildcard matches array');
assert.strictEqual(parsedTypeCheck(wildcardAst, null), true, 'Wildcard matches null');
// 3. Homogeneous arrays and fixed-length tuples
const arrayAst = parseType('[Number]');
assert.strictEqual(parsedTypeCheck(arrayAst, [10, 20, 30]), true, 'Array AST matches homogeneous numbers');
assert.strictEqual(parsedTypeCheck(arrayAst, [10, '20', 30]), false, 'Array AST rejects mixed types');
assert.strictEqual(parsedTypeCheck(arrayAst, []), true, 'Array AST matches empty array');
const tupleAst = parseType('(String, Number, Boolean)');
assert.strictEqual(parsedTypeCheck(tupleAst, ['alpha', 1, true]), true, 'Tuple AST matches exact element types');
assert.strictEqual(parsedTypeCheck(tupleAst, ['alpha', 1]), false, 'Tuple AST rejects insufficient elements');
assert.strictEqual(parsedTypeCheck(tupleAst, ['alpha', 1, true, 'extra']), false, 'Tuple AST rejects extra elements');
// 4. Closed object records, optional fields with Maybe, and open records with ...
const closedObjAst = parseType('{id: Number, name: String}');
assert.strictEqual(parsedTypeCheck(closedObjAst, { id: 1, name: 'item' }), true, 'Closed object matches exact schema');
assert.strictEqual(parsedTypeCheck(closedObjAst, { id: 1 }), false, 'Closed object rejects missing field');
assert.strictEqual(parsedTypeCheck(closedObjAst, { id: 1, name: 'item', extra: true }), false, 'Closed object rejects extraneous field');
const maybeFieldAst = parseType('{id: Number, description: Maybe String}');
assert.strictEqual(parsedTypeCheck(maybeFieldAst, { id: 2 }), true, 'Maybe field passes when omitted');
assert.strictEqual(parsedTypeCheck(maybeFieldAst, { id: 2, description: null }), true, 'Maybe field passes with null');
assert.strictEqual(parsedTypeCheck(maybeFieldAst, { id: 2, description: 'text' }), true, 'Maybe field passes with string');
const openRecordAst = parseType('{id: Number, ...}');
assert.strictEqual(parsedTypeCheck(openRecordAst, { id: 3, flag: true, extra: [1] }), true, 'Open record accepts extraneous fields');
assert.strictEqual(parsedTypeCheck(openRecordAst, { flag: true }), false, 'Open record rejects missing required field');
// 5. Custom types via customTypes option
const options = {
customTypes: {
EvenNumber: {
typeOf: 'Number',
validate: (x) => x % 2 === 0,
},
},
};
const customAst = parseType('EvenNumber');
assert.strictEqual(parsedTypeCheck(customAst, 4, options), true, 'Custom type matches even number');
assert.strictEqual(parsedTypeCheck(customAst, 7, options), false, 'Custom type rejects odd number');
assert.strictEqual(parsedTypeCheck(customAst, '4', options), false, 'Custom type rejects string');
// 6. Direct AST structures without parseType
const directNumAst = [{ type: 'Number' }];
assert.strictEqual(parsedTypeCheck(directNumAst, 50), true, 'Direct AST matches valid input');
assert.strictEqual(parsedTypeCheck(directNumAst, '50'), false, 'Direct AST rejects mismatched input');
// 7. Helper functions from module
assert.strictEqual(checkParsedType(numAst, 99), true, 'Helper checkParsedType works with parsed AST');
assert.strictEqual(compileAndCheck('String', 'verified'), true, 'Helper compileAndCheck parses and validates');
console.log('All parsedTypeCheck contract assertions passed.');
Ursprungs-Seeder
anonym