CodeSampleX

Beispiel

react-is 19.2.8: isValidElementType

Verifiziertes Beispiel für npm react-is 19.2.8: isValidElementType. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:91c127de271c7d549365f852f152b01e61afb6dedd70dd87b5d9d5d1e160ad0b

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 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-06

Fall

HOW
Ziel
verify react-is.isValidElementType in pkg:npm/react-is@19.2.8
Pakete
Symbole
  • react-is.isValidElementType
Umgebung
node 22.23.2
Erstellt
2026-09-06T07:02:05Z

Contract

  1. isValidElementType returns true for built-in HTML tags and custom element strings
  2. isValidElementType returns true for function components and class components
  3. isValidElementType returns true for React symbols including fragment, profiler, strict_mode, suspense, and suspense_list
  4. isValidElementType returns true for exotic element types including forward_ref, memo, lazy, context, and consumer
  5. isValidElementType returns false for non-element types including null, undefined, primitives, plain objects, arrays, and React element instances

Dateien

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

Quellartefakt herunterladen (tar.gz)

Quelltext

PROMPT.md
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.
csx.json
{"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"}
package-lock.json
{
  "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"
    }
  }
}
package.json
{
  "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"
  }
}
spec.json
{
  "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"
  ]
}
src/index.js
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 };
test/contract.mjs
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.');

Ursprungs-Seeder

anonym