示例
react-is 19.2.8: isValidElementType
已验证示例 — npm react-is 19.2.8: isValidElementType. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: isValidElementType returns true for built-in HTML…
sha256:91c127de271c7d549365f852f152b01e61afb6dedd70dd87b5d9d5d1e160ad0b
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 npm 10
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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-06 |
案例
HOW- 目标
- verify react-is.isValidElementType in pkg:npm/react-is@19.2.8
- 符号
-
- react-is.isValidElementType
- 环境
- node 22.23.2
- 创建时间
- 2026-09-06T07:02:05Z
契约
- isValidElementType returns true for built-in HTML tags and custom element strings
- isValidElementType returns true for function components and class components
- isValidElementType returns true for React symbols including fragment, profiler, strict_mode, suspense, and suspense_list
- isValidElementType returns true for exotic element types including forward_ref, memo, lazy, context, and consumer
- isValidElementType returns false for non-element types including null, undefined, primitives, plain objects, arrays, and React element instances
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- 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 react-is.isValidElementType in pkg:npm/react-is@19.2.8
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/react-is@19.2.8
Demonstrate these symbols/APIs:
- react-is.isValidElementType
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:511e3f2cd5aa75b4d6bf7af8462c4e208cb9c4a4eefc78dd19cb7800b5a639d8","contract":["isValidElementType returns true for built-in HTML tags and custom element strings","isValidElementType returns true for function components and class components","isValidElementType returns true for React symbols including fragment, profiler, strict_mode, suspense, and suspense_list","isValidElementType returns true for exotic element types including forward_ref, memo, lazy, context, and consumer","isValidElementType returns false for non-element types including null, undefined, primitives, plain objects, arrays, and React element instances"],"goal":"verify react-is.isValidElementType in pkg:npm/react-is@19.2.8","kind":"HOW","packages":["pkg:npm/react-is@19.2.8"],"schemaVersion":1,"symbols":["react-is.isValidElementType"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/react-is@19.2.8"],"schemaVersion":1,"subject":"pkg:npm/react-is@19.2.8","symbols":["react-is.isValidElementType"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-react-is-is-valid-element-type",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-react-is-is-valid-element-type",
"version": "1.0.0",
"dependencies": {
"react-is": "19.2.8"
}
},
"node_modules/react-is": {
"version": "19.2.8",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-19.2.8.tgz",
"integrity": "sha512-s5un28nYxKJw5gvUHyW5PCC28CvBqLu9r3cWgzHT4Vo/5fqqkFcdRYsGcKf50WMPpjjFZS5d76fn3YCo2njKwQ==",
"license": "MIT"
}
}
}
{
"name": "sample-react-is-is-valid-element-type",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of react-is.isValidElementType in pkg:npm/react-is@19.2.8",
"type": "module",
"main": "src/index.js",
"dependencies": {
"react-is": "19.2.8"
}
}
{
"schemaVersion": 1,
"goal": "verify react-is.isValidElementType in pkg:npm/react-is@19.2.8",
"kind": "HOW",
"packages": [
"pkg:npm/react-is@19.2.8"
],
"symbols": [
"react-is.isValidElementType"
]
}
import { isValidElementType } from 'react-is';
/**
* Check if the given value is a valid React element type.
*
* @param {*} value - The value to check.
* @returns {boolean} True if the value is a valid React element type.
*/
export function checkIsValidElementType(value) {
return isValidElementType(value);
}
export { isValidElementType };
import assert from 'node:assert/strict';
import { isValidElementType, checkIsValidElementType } from '../src/index.js';
// 1. Function export verification
assert.equal(typeof isValidElementType, 'function', 'isValidElementType should be a function');
assert.equal(typeof checkIsValidElementType, 'function', 'checkIsValidElementType helper should be a function');
// 2. Built-in HTML tags and custom element strings
assert.equal(isValidElementType('div'), true, 'div tag is a valid element type');
assert.equal(isValidElementType('span'), true, 'span tag is a valid element type');
assert.equal(isValidElementType('custom-element'), true, 'custom element tag is a valid element type');
assert.equal(checkIsValidElementType('my-component'), true, 'checkIsValidElementType returns true for custom tag');
// 3. Function components and class components
function FunctionalComponent() {
return null;
}
const ArrowComponent = () => null;
class ClassComponent {}
assert.equal(isValidElementType(FunctionalComponent), true, 'Function component is a valid element type');
assert.equal(isValidElementType(ArrowComponent), true, 'Arrow function component is a valid element type');
assert.equal(isValidElementType(ClassComponent), true, 'Class component is a valid element type');
assert.equal(checkIsValidElementType(FunctionalComponent), true, 'checkIsValidElementType returns true for function component');
// 4. React built-in symbols
const REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
const REACT_PROFILER_TYPE = Symbol.for('react.profiler');
const REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
const REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
const REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
assert.equal(isValidElementType(REACT_FRAGMENT_TYPE), true, 'Fragment symbol is a valid element type');
assert.equal(isValidElementType(REACT_PROFILER_TYPE), true, 'Profiler symbol is a valid element type');
assert.equal(isValidElementType(REACT_STRICT_MODE_TYPE), true, 'StrictMode symbol is a valid element type');
assert.equal(isValidElementType(REACT_SUSPENSE_TYPE), true, 'Suspense symbol is a valid element type');
assert.equal(isValidElementType(REACT_SUSPENSE_LIST_TYPE), true, 'SuspenseList symbol is a valid element type');
// 5. Exotic element types
const forwardRefType = { $$typeof: Symbol.for('react.forward_ref'), render: () => null };
const memoType = { $$typeof: Symbol.for('react.memo'), type: () => null };
const lazyType = { $$typeof: Symbol.for('react.lazy'), _payload: {}, _init: () => {} };
const contextType = { $$typeof: Symbol.for('react.context'), _context: {} };
const consumerType = { $$typeof: Symbol.for('react.consumer'), _context: {} };
assert.equal(isValidElementType(forwardRefType), true, 'ForwardRef object is a valid element type');
assert.equal(isValidElementType(memoType), true, 'Memo object is a valid element type');
assert.equal(isValidElementType(lazyType), true, 'Lazy object is a valid element type');
assert.equal(isValidElementType(contextType), true, 'Context object is a valid element type');
assert.equal(isValidElementType(consumerType), true, 'Consumer object is a valid element type');
assert.equal(checkIsValidElementType(forwardRefType), true, 'checkIsValidElementType returns true for forwardRef');
// 6. Non-element types (negative assertions)
assert.equal(isValidElementType(null), false, 'null is not a valid element type');
assert.equal(isValidElementType(undefined), false, 'undefined is not a valid element type');
assert.equal(isValidElementType(123), false, 'Number is not a valid element type');
assert.equal(isValidElementType(true), false, 'Boolean is not a valid element type');
assert.equal(isValidElementType(false), false, 'Boolean is not a valid element type');
assert.equal(isValidElementType({}), false, 'Plain empty object is not a valid element type');
assert.equal(isValidElementType([]), false, 'Array is not a valid element type');
assert.equal(isValidElementType(Symbol('arbitrary')), false, 'Arbitrary symbol is not a valid element type');
assert.equal(isValidElementType(Symbol.for('react.portal')), false, 'Portal symbol is not a valid element type');
const elementInstance = {
$$typeof: Symbol.for('react.transitional.element'),
type: 'div',
props: {},
key: null,
ref: null,
};
assert.equal(isValidElementType(elementInstance), false, 'React element instance is not a valid element type');
assert.equal(checkIsValidElementType(elementInstance), false, 'checkIsValidElementType returns false for element instance');
console.log('Contract tests passed successfully.');
原始种子者
匿名