Пример
@types/react-dom 19.2.4: peerDependencies
Проверенный пример — npm @types/react-dom 19.2.4: peerDependencies. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден.
sha256:10a851bac74cca0fa1bbfce2288dec6b246b15f1f3246860043830df52dd2984
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 2
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 24 · ubuntu · glibc 2.39 x64 npm
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| 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 |
Кейс
HOW- Цель
- verify @types/react-dom.peerDependencies in pkg:npm/%40types/react-dom@19.2.4
- Пакеты
- Символы
-
- @types/react-dom.peerDependencies
- Создан
- 2026-08-26T12:39:36Z
Контракт
- @types/react-dom package.json declares peerDependencies field containing @types/react
- peerDependencies @types/react specifies semver range satisfying React 19 (^19.2.0)
- package.json separates peer type requirements from dependencies by leaving dependencies empty
- index.d.ts imports React core types from peer dependency and augments react module
- client.d.ts imports React namespace from peer dependency for root APIs
- server.d.ts and static.d.ts declarations consume React peer types for streaming and prerendering APIs
- Helper inspection functions validate peer dependency declarations, semver constraints, and peer type integration across all entrypoints
Файлы
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
Исходный код
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 @types/react-dom.peerDependencies in pkg:npm/%40types/react-dom@19.2.4
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40types/react-dom@19.2.4
Demonstrate these symbols/APIs:
- @types/react-dom.peerDependencies
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:bd691b0bc76f755840e3e33829f23e7a1eb0058c069b5c904b0af5f2f55356bf","contract":["@types/react-dom package.json declares peerDependencies field containing @types/react","peerDependencies @types/react specifies semver range satisfying React 19 (^19.2.0)","package.json separates peer type requirements from dependencies by leaving dependencies empty","index.d.ts imports React core types from peer dependency and augments react module","client.d.ts imports React namespace from peer dependency for root APIs","server.d.ts and static.d.ts declarations consume React peer types for streaming and prerendering APIs","Helper inspection functions validate peer dependency declarations, semver constraints, and peer type integration across all entrypoints"],"goal":"verify @types/react-dom.peerDependencies in pkg:npm/%40types/react-dom@19.2.4","kind":"HOW","packages":["pkg:npm/%40types/react-dom@19.2.4"],"schemaVersion":1,"symbols":["@types/react-dom.peerDependencies"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40types/react-dom@19.2.4"],"schemaVersion":1,"subject":"pkg:npm/%40types/react-dom@19.2.4","symbols":["@types/react-dom.peerDependencies"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-react-dom-peerdeps",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-react-dom-peerdeps",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@types/react-dom": "19.2.4"
}
},
"node_modules/@types/react": {
"version": "19.2.18",
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.18.tgz",
"integrity": "sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==",
"license": "MIT",
"peer": true,
"dependencies": {
"csstype": "^3.2.2"
}
},
"node_modules/@types/react-dom": {
"version": "19.2.4",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.4.tgz",
"integrity": "sha512-Bsc+QHgp+P/F02XDzNCY9jnZNCUuLki36KT7VKrTXXLdHf+vHMNZnW1rVu5DNW/rCK+fya3DATySbLM4yhtKUw==",
"license": "MIT",
"peerDependencies": {
"@types/react": "^19.2.0"
}
},
"node_modules/csstype": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
"license": "MIT",
"peer": true
}
}
}
{
"name": "sample-react-dom-peerdeps",
"version": "1.0.0",
"private": true,
"license": "MIT-0",
"dependencies": {
"@types/react-dom": "19.2.4"
}
}
{
"schemaVersion": 1,
"goal": "verify @types/react-dom.peerDependencies in pkg:npm/%40types/react-dom@19.2.4",
"kind": "HOW",
"packages": [
"pkg:npm/%40types/react-dom@19.2.4"
],
"symbols": [
"@types/react-dom.peerDependencies"
]
}
import fs from 'node:fs';
import path from 'node:path';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
/**
* Resolves the root directory of the installed @types/react-dom package.
* @returns {string} Package directory path
*/
export function getReactDomPackageDir() {
const pkgPath = require.resolve('@types/react-dom/package.json');
return path.dirname(pkgPath);
}
/**
* Returns the parsed package.json manifest of @types/react-dom.
* @returns {object} Package JSON object
*/
export function getReactDomPackageJson() {
const pkgPath = require.resolve('@types/react-dom/package.json');
return JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
}
/**
* Returns the peerDependencies declared by @types/react-dom.
* @returns {object} Peer dependencies map
*/
export function getReactDomPeerDependencies() {
const pkg = getReactDomPackageJson();
return pkg.peerDependencies || {};
}
/**
* Validates whether @types/react peer dependency is present and satisfies React 19 range.
* @param {string} [packageName='@types/react'] - Name of the peer dependency to inspect
* @returns {{ exists: boolean, range: string, isReact19: boolean }}
*/
export function validateReactPeerDependency(packageName = '@types/react') {
const peerDeps = getReactDomPeerDependencies();
const range = peerDeps[packageName];
const exists = typeof range === 'string';
const isReact19 = exists && (range.startsWith('^19.') || range.startsWith('~19.') || range.includes('19.'));
return { exists, range: range || '', isReact19 };
}
/**
* Resolves the path to a declaration file in @types/react-dom.
* @param {string} [subPath='index.d.ts'] - Declaration relative file name
* @returns {string} Absolute path to declaration file
*/
export function getDeclarationPath(subPath = 'index.d.ts') {
return path.join(getReactDomPackageDir(), subPath);
}
/**
* Loads text content of a declaration file in @types/react-dom.
* @param {string} [subPath='index.d.ts'] - Declaration relative file name
* @returns {string} Text content of declaration file
*/
export function loadDeclarationContent(subPath = 'index.d.ts') {
const declPath = getDeclarationPath(subPath);
return fs.readFileSync(declPath, 'utf8');
}
/**
* Inspects React peer type references and imports across all @types/react-dom declaration files.
* @returns {object} Summary of peer type usage
*/
export function inspectPeerTypeIntegrations() {
const indexContent = loadDeclarationContent('index.d.ts');
const clientContent = loadDeclarationContent('client.d.ts');
const serverContent = loadDeclarationContent('server.d.ts');
const staticContent = loadDeclarationContent('static.d.ts');
return {
index: {
hasReactImports: indexContent.includes('from "react"') || indexContent.includes("from 'react'"),
declaresReactModuleAugmentation: indexContent.includes('declare module "react"') || indexContent.includes("declare module 'react'")
},
client: {
importsReactNamespace: clientContent.includes('import React = require("react");') || clientContent.includes("import React = require('react');"),
usesReactElement: clientContent.includes('React.') || clientContent.includes('ReactNode')
},
server: {
importsReactNamespace: serverContent.includes('require("react")') || serverContent.includes("require('react')") || serverContent.includes('from "react"'),
usesReactNode: serverContent.includes('ReactNode') || serverContent.includes('React.ReactNode')
},
static: {
importsReactNamespace: staticContent.includes('require("react")') || staticContent.includes("require('react')") || staticContent.includes('from "react"'),
usesReactNode: staticContent.includes('ReactNode') || staticContent.includes('React.ReactNode')
}
};
}
import assert from 'node:assert/strict';
import fs from 'node:fs';
import { createRequire } from 'node:module';
import {
getReactDomPackageDir,
getReactDomPackageJson,
getReactDomPeerDependencies,
validateReactPeerDependency,
getDeclarationPath,
loadDeclarationContent,
inspectPeerTypeIntegrations
} from '../src/index.mjs';
const require = createRequire(import.meta.url);
// Contract 1: @types/react-dom package.json declares peerDependencies field containing @types/react
{
const pkgJson = getReactDomPackageJson();
assert.equal(pkgJson.name, '@types/react-dom');
assert.equal(pkgJson.version, '19.2.4');
assert.ok(pkgJson.peerDependencies, 'peerDependencies field must be present');
assert.ok(pkgJson.peerDependencies['@types/react'], '@types/react must be listed in peerDependencies');
}
// Contract 2: peerDependencies @types/react specifies semver range satisfying React 19 (^19.2.0)
{
const peerDeps = getReactDomPeerDependencies();
assert.equal(peerDeps['@types/react'], '^19.2.0');
const validation = validateReactPeerDependency('@types/react');
assert.equal(validation.exists, true);
assert.equal(validation.isReact19, true);
assert.equal(validation.range, '^19.2.0');
}
// Contract 3: package.json separates peer type requirements from dependencies by leaving dependencies empty
{
const pkgJson = getReactDomPackageJson();
assert.deepEqual(pkgJson.dependencies, {}, 'dependencies must be empty as typing dependencies are declared in peerDependencies');
}
// Contract 4: index.d.ts imports React core types from peer dependency and augments react module
{
const indexContent = loadDeclarationContent('index.d.ts');
assert.ok(indexContent.includes('import { Key, ReactNode, ReactPortal } from "react";'), 'index.d.ts must import Key, ReactNode, ReactPortal from react');
assert.ok(indexContent.includes('declare module "react"'), 'index.d.ts must declare module augmentation for react');
}
// Contract 5: client.d.ts imports React namespace from peer dependency for root APIs
{
const clientContent = loadDeclarationContent('client.d.ts');
assert.ok(clientContent.includes('import React = require("react");'), 'client.d.ts must import React namespace');
assert.ok(clientContent.includes('React.ReactNode'), 'client.d.ts must reference React.ReactNode type');
}
// Contract 6: server.d.ts and static.d.ts declarations consume React peer types for streaming and prerendering APIs
{
const serverContent = loadDeclarationContent('server.d.ts');
const staticContent = loadDeclarationContent('static.d.ts');
assert.ok(serverContent.includes('React.ReactNode') || serverContent.includes('ReactNode'), 'server.d.ts must consume React node types');
assert.ok(staticContent.includes('React.ReactNode') || staticContent.includes('ReactNode'), 'static.d.ts must consume React node types');
}
// Contract 7: Helper inspection functions validate peer dependency declarations, semver constraints, and peer type integration across all entrypoints
{
const dir = getReactDomPackageDir();
assert.ok(fs.existsSync(dir), 'Package directory must exist');
const declPath = getDeclarationPath('index.d.ts');
assert.ok(fs.existsSync(declPath), 'Declaration file index.d.ts must exist');
const integrations = inspectPeerTypeIntegrations();
assert.equal(integrations.index.hasReactImports, true);
assert.equal(integrations.index.declaresReactModuleAugmentation, true);
assert.equal(integrations.client.importsReactNamespace, true);
assert.equal(integrations.client.usesReactElement, true);
assert.equal(integrations.server.importsReactNamespace, true);
assert.equal(integrations.static.importsReactNamespace, true);
}
console.log('All @types/react-dom.peerDependencies contract tests passed successfully.');
Исходный сидер
аноним