Registry / testing / json-schema-spec-types

json-schema-spec-types

JSON →
library0.1.2jsnpmunverified

TypeScript type definitions for JSON Schema specification draft-07. Current version 0.1.2, released sporadically. Generated from the official JSON Schema spec schema and refined. Provides precise types for JSON Schema objects, aiding validation and autocompletion. Key differentiator: focus on draft-07 with niche coverage; alternatives include @types/json-schema for broader draft support.

npm install json-schema-spec-types
INSTALL
IMPORT
SIG · JSON-SCHEMA-SPEC-T
J
json-schema-spec-types
testingjavascriptv0.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JSONSchema
import type { JSONSchema } from 'json-schema-spec-types'
import { JSONSchema } from 'json-schema-spec-types'
Use 'import type' since this is a type-only package; runtime import yields undefined.
default
import JSONSchema from 'json-schema-spec-types'
const JSONSchema = require('json-schema-spec-types')
Default export is the JSONSchema type; CommonJS require returns an object, not the type.
JsonSchema
import type { JsonSchema } from 'json-schema-spec-types'
import { JsonSchema } from 'json-schema-spec-types'
Alias for JSONSchema, same import rules apply.

Define a JSON Schema object with TypeScript types from json-schema-spec-types.

import type { JSONSchema } from 'json-schema-spec-types'; const schema: JSONSchema = { type: 'object', properties: { name: { type: 'string' }, age: { type: 'integer', minimum: 0 } }, required: ['name'] }; // Validate against JSON Schema (using external validator) // import Ajv from 'ajv'; // const ajv = new Ajv(); // const validate = ajv.compile(schema); // const data = { name: 'Alice', age: 30 }; // const valid = validate(data); // true
Debug
Known issues
breakingPackage is type-only; using runtime import (e.g., require) returns empty object.
fix
Use 'import type' or skip runtime usage.
affects: >=0.0.1
deprecatedDraft-07 is superseded by later drafts (2019-09, 2020-12). This package only covers draft-07.
fix
Consider using '@types/json-schema' for broader draft support.
affects: >=0.0.1
gotchaType names are exported as 'JSONSchema' and 'JsonSchema' (alias). Both are the same type.
fix
Use either; consistency recommended.
affects: >=0.0.1
breakingAll exports are type-only; no const/function exports. CommonJS require will not work as expected.
fix
Set 'esModuleInterop' to false if using CommonJS, or always use 'import type'.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: JSONSchema is not a constructor
Used runtime import (import JSONSchema from ...) without 'type' keyword.
fix
Use 'import type { JSONSchema } from ...' or 'import type JSONSchema from ...'.
Module '"json-schema-spec-types"' has no exported member 'JSONSchema'.
Importing from wrong path or misspelling.
fix
Ensure import path is correct: 'json-schema-spec-types' and check case: 'JSONSchema' (note capital S).
Cannot use namespace 'JSONSchema' as a type.
Tried to use the type in a value position (e.g., instanceof).
fix
JSONSchema is a type only; use it for type annotations, not runtime.
Upgrade
Version history
0.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
Amazon
1
Resources
json-schema-spec-types — npm install json-schema-spec-types · libregistry