示例
react-is 19.2.8: typeOf
已验证示例 — npm react-is 19.2.8: typeOf. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: typeOf identifies standard React DOM and component elements…
sha256:0e32432ee2e212e42bb8b4d5e429747bcc2310b1542eb7f6004d9f6992a53340
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript 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.typeOf in pkg:npm/react-is@19.2.8
- 符号
-
- react-is.typeOf
- 环境
- node 22.23.2
- 创建时间
- 2026-09-06T02:14:09Z
契约
- typeOf identifies standard React DOM and component elements returning Element symbol
- typeOf identifies React fragment elements returning Fragment symbol
- typeOf identifies React portal objects returning Portal symbol
- typeOf identifies ContextProvider elements returning ContextProvider symbol
- typeOf identifies ContextConsumer elements returning ContextConsumer symbol
- typeOf identifies ForwardRef component elements returning ForwardRef symbol
- typeOf identifies Lazy component elements returning Lazy symbol
- typeOf identifies Memo component elements returning Memo symbol
- typeOf identifies Profiler elements returning Profiler symbol
- typeOf identifies StrictMode elements returning StrictMode symbol
- typeOf identifies Suspense elements returning Suspense symbol
- typeOf identifies SuspenseList elements returning SuspenseList symbol
- typeOf returns undefined for plain objects, null, undefined, and primitive types
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
源代码
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.typeOf 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.typeOf
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.
{"case":{"caseId":"case:sha256:18341b0e80f506e98dd54aa467abf71a091badf82d517a65e6a1472681887ea0","constraints":{"executionContext":"node"},"contract":["typeOf identifies standard React DOM and component elements returning Element symbol","typeOf identifies React fragment elements returning Fragment symbol","typeOf identifies React portal objects returning Portal symbol","typeOf identifies ContextProvider elements returning ContextProvider symbol","typeOf identifies ContextConsumer elements returning ContextConsumer symbol","typeOf identifies ForwardRef component elements returning ForwardRef symbol","typeOf identifies Lazy component elements returning Lazy symbol","typeOf identifies Memo component elements returning Memo symbol","typeOf identifies Profiler elements returning Profiler symbol","typeOf identifies StrictMode elements returning StrictMode symbol","typeOf identifies Suspense elements returning Suspense symbol","typeOf identifies SuspenseList elements returning SuspenseList symbol","typeOf returns undefined for plain objects, null, undefined, and primitive types"],"goal":"verify react-is.typeOf in pkg:npm/react-is@19.2.8","kind":"HOW","packages":["pkg:npm/react-is@19.2.8"],"schemaVersion":1,"symbols":["react-is.typeOf"]},"contractCommand":["node","test/contract.js"],"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/react-is@19.2.8"],"schemaVersion":1,"subject":"pkg:npm/react-is@19.2.8","symbols":["react-is.typeOf"],"verifierAdapter":"node-typescript@1"}
{
"name": "verify-react-is-typeof",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "verify-react-is-typeof",
"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": "verify-react-is-typeof",
"version": "1.0.0",
"description": "verify react-is.typeOf in pkg:npm/react-is@19.2.8",
"main": "src/index.js",
"dependencies": {
"react-is": "19.2.8"
}
}
{
"schemaVersion": 1,
"goal": "verify react-is.typeOf in pkg:npm/react-is@19.2.8",
"kind": "HOW",
"packages": [
"pkg:npm/react-is@19.2.8"
],
"symbols": [
"react-is.typeOf"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const {
typeOf,
ContextConsumer,
ContextProvider,
Element,
ForwardRef,
Fragment,
Lazy,
Memo,
Portal,
Profiler,
StrictMode,
Suspense,
SuspenseList,
} = require('react-is');
/**
* Inspects a value and returns its React element type symbol, or undefined if not a React element.
*
* @param {*} value - Value to inspect.
* @returns {symbol|undefined} The React symbol or undefined.
*/
function inspectTypeOf(value) {
return typeOf(value);
}
module.exports = {
typeOf,
inspectTypeOf,
ContextConsumer,
ContextProvider,
Element,
ForwardRef,
Fragment,
Lazy,
Memo,
Portal,
Profiler,
StrictMode,
Suspense,
SuspenseList,
};
const assert = require('node:assert/strict');
const {
typeOf,
inspectTypeOf,
ContextConsumer,
ContextProvider,
Element,
ForwardRef,
Fragment,
Lazy,
Memo,
Portal,
Profiler,
StrictMode,
Suspense,
SuspenseList,
} = require('../src/index.js');
// 1. Export verification
assert.equal(typeof typeOf, 'function', 'typeOf must be a function');
assert.equal(typeof inspectTypeOf, 'function', 'inspectTypeOf must be a function');
assert.equal(typeof Element, 'symbol', 'Element must be a symbol');
assert.equal(typeof Fragment, 'symbol', 'Fragment must be a symbol');
assert.equal(typeof Portal, 'symbol', 'Portal must be a symbol');
assert.equal(typeof ContextProvider, 'symbol', 'ContextProvider must be a symbol');
assert.equal(typeof ContextConsumer, 'symbol', 'ContextConsumer must be a symbol');
assert.equal(typeof ForwardRef, 'symbol', 'ForwardRef must be a symbol');
assert.equal(typeof Lazy, 'symbol', 'Lazy must be a symbol');
assert.equal(typeof Memo, 'symbol', 'Memo must be a symbol');
assert.equal(typeof Profiler, 'symbol', 'Profiler must be a symbol');
assert.equal(typeof StrictMode, 'symbol', 'StrictMode must be a symbol');
assert.equal(typeof Suspense, 'symbol', 'Suspense must be a symbol');
assert.equal(typeof SuspenseList, 'symbol', 'SuspenseList must be a symbol');
// React 19 symbols
const REACT_ELEMENT_TYPE = Symbol.for('react.transitional.element');
const REACT_PORTAL_TYPE = Symbol.for('react.portal');
const REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
const REACT_CONTEXT_TYPE = Symbol.for('react.context');
const REACT_CONSUMER_TYPE = Symbol.for('react.consumer');
const REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
const REACT_LAZY_TYPE = Symbol.for('react.lazy');
const REACT_MEMO_TYPE = Symbol.for('react.memo');
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');
// 2. Standard React elements
const domElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: 'div',
props: { id: 'root' },
key: null,
ref: null,
};
assert.equal(typeOf(domElement), Element, 'typeOf(domElement) must return Element symbol');
assert.equal(inspectTypeOf(domElement), Element, 'inspectTypeOf(domElement) must return Element symbol');
const fnComponentElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: function MyComponent() { return null; },
props: {},
key: null,
ref: null,
};
assert.equal(typeOf(fnComponentElement), Element, 'typeOf(fnComponentElement) must return Element symbol');
// 3. Fragment element
const fragmentElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: REACT_FRAGMENT_TYPE,
props: { children: [] },
key: null,
ref: null,
};
assert.equal(typeOf(fragmentElement), Fragment, 'typeOf(fragmentElement) must return Fragment symbol');
// 4. Portal object
const portalObject = {
$$typeof: REACT_PORTAL_TYPE,
key: null,
children: [],
containerInfo: {},
};
assert.equal(typeOf(portalObject), Portal, 'typeOf(portalObject) must return Portal symbol');
// 5. ContextProvider element
const providerElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: {
$$typeof: REACT_CONTEXT_TYPE,
_context: {},
},
props: { value: 'test' },
key: null,
ref: null,
};
assert.equal(typeOf(providerElement), ContextProvider, 'typeOf(providerElement) must return ContextProvider symbol');
// 6. ContextConsumer element
const consumerElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: {
$$typeof: REACT_CONSUMER_TYPE,
},
props: { children: () => null },
key: null,
ref: null,
};
assert.equal(typeOf(consumerElement), ContextConsumer, 'typeOf(consumerElement) must return ContextConsumer symbol');
// 7. ForwardRef element
const forwardRefElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: {
$$typeof: REACT_FORWARD_REF_TYPE,
render: (props, ref) => null,
},
props: {},
key: null,
ref: null,
};
assert.equal(typeOf(forwardRefElement), ForwardRef, 'typeOf(forwardRefElement) must return ForwardRef symbol');
// 8. Lazy component element
const lazyElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: {
$$typeof: REACT_LAZY_TYPE,
_payload: {},
_init: () => null,
},
props: {},
key: null,
ref: null,
};
assert.equal(typeOf(lazyElement), Lazy, 'typeOf(lazyElement) must return Lazy symbol');
// 9. Memo component element
const memoElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: {
$$typeof: REACT_MEMO_TYPE,
type: 'span',
compare: null,
},
props: {},
key: null,
ref: null,
};
assert.equal(typeOf(memoElement), Memo, 'typeOf(memoElement) must return Memo symbol');
// 10. Profiler element
const profilerElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: REACT_PROFILER_TYPE,
props: { id: 'app-profiler', onRender: () => {} },
key: null,
ref: null,
};
assert.equal(typeOf(profilerElement), Profiler, 'typeOf(profilerElement) must return Profiler symbol');
// 11. StrictMode element
const strictModeElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: REACT_STRICT_MODE_TYPE,
props: { children: [] },
key: null,
ref: null,
};
assert.equal(typeOf(strictModeElement), StrictMode, 'typeOf(strictModeElement) must return StrictMode symbol');
// 12. Suspense element
const suspenseElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: REACT_SUSPENSE_TYPE,
props: { fallback: null, children: [] },
key: null,
ref: null,
};
assert.equal(typeOf(suspenseElement), Suspense, 'typeOf(suspenseElement) must return Suspense symbol');
// 13. SuspenseList element
const suspenseListElement = {
$$typeof: REACT_ELEMENT_TYPE,
type: REACT_SUSPENSE_LIST_TYPE,
props: { children: [] },
key: null,
ref: null,
};
assert.equal(typeOf(suspenseListElement), SuspenseList, 'typeOf(suspenseListElement) must return SuspenseList symbol');
// 14. Non-element values return undefined
assert.equal(typeOf({}), undefined, 'typeOf on empty object must return undefined');
assert.equal(typeOf({ type: 'div' }), undefined, 'typeOf on object without $$typeof must return undefined');
assert.equal(typeOf(null), undefined, 'typeOf on null must return undefined');
assert.equal(typeOf(undefined), undefined, 'typeOf on undefined must return undefined');
assert.equal(typeOf('div'), undefined, 'typeOf on string primitive must return undefined');
assert.equal(typeOf(12345), undefined, 'typeOf on number primitive must return undefined');
assert.equal(typeOf(true), undefined, 'typeOf on boolean primitive must return undefined');
console.log('Contract test for react-is.typeOf in pkg:npm/react-is@19.2.8 passed.');
原始种子者
匿名