Пример
@types/babel__traverse 7.28.0
Проверенный пример — npm @types/babel__traverse 7.28.0. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: package manifest specifies…
sha256:60f36e7522592c020cc45e86bc5665f008fa0b05fc64613be5a636bd301e7246
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| 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-23 |
Кейс
HOW- Цель
- verify pkg:npm/%40types/babel__traverse@7.28.0
- Окружение
- node 22.23.2
- Создан
- 2026-08-23T14:59:20Z
Контракт
- package manifest specifies index.d.ts type declarations, TypeScript version 5.1, and @babel/types dependency
- traverse main export declares AST traversal overloads with TraverseOptions, Scope, and NodePath
- visitors namespace declares explode, verify, and merge utility functions for visitor normalization
- Visitor and TraverseOptions types support per-node handlers, aliases, virtual types, and state
- NodePath class declares AST node navigation, ancestry inspection, replacement, and traversal methods
- Scope and Binding classes declare lexical scope management, identifier tracking, and UID generation
- HubInterface, Hub class, and TraversalContext declare code context and error creation
Файлы
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Исходный код
{"case":{"caseId":"case:sha256:f274beaf3122e27d048faa392bf02e965ab0117c1da32efdafc4a18c40afce75","contract":["package manifest specifies index.d.ts type declarations, TypeScript version 5.1, and @babel/types dependency","traverse main export declares AST traversal overloads with TraverseOptions, Scope, and NodePath","visitors namespace declares explode, verify, and merge utility functions for visitor normalization","Visitor and TraverseOptions types support per-node handlers, aliases, virtual types, and state","NodePath class declares AST node navigation, ancestry inspection, replacement, and traversal methods","Scope and Binding classes declare lexical scope management, identifier tracking, and UID generation","HubInterface, Hub class, and TraversalContext declare code context and error creation"],"goal":"verify pkg:npm/%40types/babel__traverse@7.28.0","kind":"HOW","packages":["pkg:npm/%40types/babel__traverse@7.28.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40types/babel__traverse@7.28.0"],"schemaVersion":1,"subject":"pkg:npm/%40types/babel__traverse@7.28.0","verifierAdapter":"node-typescript@1"}
{
"name": "sample-types-babel-traverse",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-types-babel-traverse",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@types/babel__traverse": "7.28.0"
}
},
"node_modules/@babel/helper-string-parser": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz",
"integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-identifier": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz",
"integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/types": {
"version": "7.29.8",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz",
"integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==",
"license": "MIT",
"dependencies": {
"@babel/helper-string-parser": "^7.29.7",
"@babel/helper-validator-identifier": "^7.29.7"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@types/babel__traverse": {
"version": "7.28.0",
"resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.28.0.tgz",
"integrity": "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==",
"license": "MIT",
"dependencies": {
"@babel/types": "^7.28.2"
}
}
}
}
{
"name": "sample-types-babel-traverse",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"@types/babel__traverse": "7.28.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40types/babel__traverse@7.28.0",
"kind": "HOW",
"packages": [
"pkg:npm/%40types/babel__traverse@7.28.0"
]
}
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import fs from 'node:fs';
import path from 'node:path';
const require = createRequire(import.meta.url);
// 1. Resolve @types/babel__traverse package manifest and verify declaration entry points
const pkgPath = require.resolve('@types/babel__traverse/package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
assert.equal(pkg.name, '@types/babel__traverse', 'Package name must be @types/babel__traverse');
assert.equal(pkg.version, '7.28.0', 'Package version must be 7.28.0');
assert.equal(pkg.types, 'index.d.ts', 'Package types entry must point to index.d.ts');
assert.equal(pkg.typeScriptVersion, '5.1', 'TypeScript version must be 5.1');
assert.ok(
pkg.dependencies && pkg.dependencies['@babel/types'],
'Package dependencies must declare @babel/types'
);
const typesDir = path.dirname(pkgPath);
const dtsContent = fs.readFileSync(path.join(typesDir, 'index.d.ts'), 'utf8');
// 2. Verify traverse main export and utility function signatures
assert.ok(
dtsContent.includes('declare const traverse: {') &&
dtsContent.includes('<S>(parent: Node, opts: TraverseOptions<S>, scope: Scope | undefined, state: S, parentPath?: NodePath): void;') &&
dtsContent.includes('(parent: Node, opts?: TraverseOptions, scope?: Scope, state?: any, parentPath?: NodePath): void;'),
'traverse function must declare AST traversal overloads with TraverseOptions, Scope, and NodePath'
);
assert.ok(
dtsContent.includes('visitors: typeof visitors;') &&
dtsContent.includes('verify: typeof visitors.verify;') &&
dtsContent.includes('explode: typeof visitors.explode;') &&
dtsContent.includes('cheap: (node: Node, enter: (node: Node) => void) => void;') &&
dtsContent.includes('node: (') &&
dtsContent.includes('clearNode: (node: Node, opts?: RemovePropertiesOptions) => void;') &&
dtsContent.includes('removeProperties: (tree: Node, opts?: RemovePropertiesOptions) => Node;') &&
dtsContent.includes('hasType: (tree: Node, type: Node["type"], denylistTypes?: string[]) => boolean;') &&
dtsContent.includes('cache: typeof cache;') &&
dtsContent.includes('export default traverse;'),
'traverse export must provide visitors, verify, explode, cheap, node, clearNode, removeProperties, and hasType utilities'
);
// 3. Verify visitors namespace functions
assert.ok(
dtsContent.includes('export namespace visitors {') &&
dtsContent.includes('function explode<S = unknown>(') &&
dtsContent.includes('function verify(visitor: Visitor): void;') &&
dtsContent.includes('function merge<State>(visitors: Array<Visitor<State>>): Visitor<State>;'),
'visitors namespace must declare explode, verify, and merge functions'
);
// 4. Verify Visitor, TraverseOptions, and VisitNode types
assert.ok(
dtsContent.includes('export type TraverseOptions<S = Node> = {') &&
dtsContent.includes('scope?: Scope;') &&
dtsContent.includes('noScope?: boolean;') &&
dtsContent.includes('denylist?: NodeType[];') &&
dtsContent.includes('shouldSkip?: (node: NodePath) => boolean;') &&
dtsContent.includes('} & Visitor<S>;'),
'TraverseOptions type must declare scope, noScope, denylist, shouldSkip, and Visitor intersection'
);
assert.ok(
dtsContent.includes('export type Visitor<S = unknown> =') &&
dtsContent.includes('& VisitNodeObject<S, Node>') &&
dtsContent.includes('[N in Node as N["type"]]?: VisitNode<S, N extends { type: N["type"] } ? N : never>;') &&
dtsContent.includes('[K in keyof t.Aliases]?: VisitNode<S, t.Aliases[K]>;') &&
dtsContent.includes('[K in keyof VirtualTypeAliases]?: VisitNode<S, VirtualTypeAliases[K]>;'),
'Visitor type must support per-node handlers, aliases, virtual types, and state'
);
assert.ok(
dtsContent.includes('export type VisitNode<S, P extends Node> = VisitNodeFunction<S, P> | VisitNodeObject<S, P>;') &&
dtsContent.includes('export type VisitNodeFunction<S, P extends Node> = (this: S, path: NodePath<P>, state: S) => void;') &&
dtsContent.includes('export interface VisitNodeObject<S, P extends Node> {') &&
dtsContent.includes('enter?: VisitNodeFunction<S, P>;') &&
dtsContent.includes('exit?: VisitNodeFunction<S, P>;'),
'VisitNodeFunction and VisitNodeObject must declare enter/exit handlers'
);
// 5. Verify NodePath class declaration and methods
assert.ok(
dtsContent.includes('export class NodePath<T = Node> {') &&
dtsContent.includes('constructor(hub: HubInterface, parent: Node);') &&
dtsContent.includes('parent: Node;') &&
dtsContent.includes('hub: Hub;') &&
dtsContent.includes('context: TraversalContext;') &&
dtsContent.includes('scope: Scope;') &&
dtsContent.includes('node: T;') &&
dtsContent.includes('type: T extends Node ? T["type"] : T extends null | undefined ? undefined : Node["type"] | undefined;'),
'NodePath class must declare parent, hub, context, scope, node, and type properties'
);
assert.ok(
dtsContent.includes('findParent(callback: (path: NodePath) => boolean): NodePath | null;') &&
dtsContent.includes('find(callback: (path: NodePath) => boolean): NodePath | null;') &&
dtsContent.includes('getFunctionParent(): NodePath<t.Function> | null;') &&
dtsContent.includes('getStatementParent(): NodePath<t.Statement> | null;') &&
dtsContent.includes('getAncestry(): [this, ...NodePath[]];') &&
dtsContent.includes('replaceWith<R extends Node>(replacementPath: R | NodePath<R>): [NodePath<R>];') &&
dtsContent.includes('replaceWithMultiple<Nodes extends Node | readonly Node[] | [Node, ...Node[]]>(nodes: Nodes): NodePaths<Nodes>;') &&
dtsContent.includes('replaceWithSourceString(replacement: string): [NodePath];') &&
dtsContent.includes('traverse<T>(visitor: TraverseOptions<T>, state: T): void;'),
'NodePath class must declare search, ancestry, replacement, and traversal methods'
);
// 6. Verify Scope and Binding classes
assert.ok(
dtsContent.includes('export class Scope {') &&
dtsContent.includes('constructor(path: NodePath, parentScope?: Scope);') &&
dtsContent.includes('bindings: { [name: string]: Binding };') &&
dtsContent.includes('references: { [name: string]: true };') &&
dtsContent.includes('globals: { [name: string]: t.Identifier | t.JSXIdentifier };') &&
dtsContent.includes('generateUidIdentifier(name?: string): t.Identifier;') &&
dtsContent.includes('generateDeclaredUidIdentifier(name?: string): t.Identifier;') &&
dtsContent.includes('generateUid(name?: string): string;') &&
dtsContent.includes('rename(oldName: string, newName?: string, block?: Node): void;') &&
dtsContent.includes('getBinding(name: string): Binding | undefined;') &&
dtsContent.includes('hasBinding('),
'Scope class must declare bindings, references, globals, identifier generators, rename, and query methods'
);
assert.ok(
dtsContent.includes('export class Binding {') &&
dtsContent.includes('constructor(opts: { identifier: t.Identifier; scope: Scope; path: NodePath; kind: BindingKind });') &&
dtsContent.includes('identifier: t.Identifier;') &&
dtsContent.includes('scope: Scope;') &&
dtsContent.includes('path: NodePath;') &&
dtsContent.includes('kind: BindingKind;') &&
dtsContent.includes('referenced: boolean;') &&
dtsContent.includes('references: number;') &&
dtsContent.includes('referencePaths: NodePath[];') &&
dtsContent.includes('constant: boolean;') &&
dtsContent.includes('constantViolations: NodePath[];') &&
dtsContent.includes('reassign(path: NodePath): void;') &&
dtsContent.includes('reference(path: NodePath): void;') &&
dtsContent.includes('dereference(): void;'),
'Binding class must declare identifier, scope, path, reference tracking, and mutation methods'
);
// 7. Verify HubInterface, Hub class, and TraversalContext
assert.ok(
dtsContent.includes('export interface HubInterface {') &&
dtsContent.includes('getCode(): string | undefined;') &&
dtsContent.includes('getScope(): Scope | undefined;') &&
dtsContent.includes('addHelper(name: string): any;') &&
dtsContent.includes('buildError(node: Node, msg: string, Error: ErrorConstructor): Error;') &&
dtsContent.includes('export class Hub implements HubInterface {') &&
dtsContent.includes('export interface TraversalContext<S = unknown> {'),
'HubInterface, Hub class, and TraversalContext must be declared'
);
console.log('Contract tests passed successfully.');
Исходный сидер
аноним