{"id":11182,"library":"jsonapi-typescript","title":"JSON:API TypeScript Types","description":"This package provides TypeScript type definitions for JSON:API documents, enabling compile-time validation of JSON:API structures within TypeScript projects. The current stable version is 0.1.3, released in April 2019. Given the lack of updates since then, its release cadence is effectively inactive, and it should be considered abandoned. Its primary differentiator is its sole focus on providing type-checking for JSON:API, without including any runtime parsing or serialization logic. This makes it a lightweight option for projects that already handle data fetching and serialization and only require type-safety enforcement against the JSON:API specification.","status":"abandoned","version":"0.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/mike-north/jsonapi-typescript","tags":["javascript","jsonapi","typescript","ember-data","emberjs"],"install":[{"cmd":"npm install jsonapi-typescript","lang":"bash","label":"npm"},{"cmd":"yarn add jsonapi-typescript","lang":"bash","label":"yarn"},{"cmd":"pnpm add jsonapi-typescript","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Primarily designed for ESM and TypeScript; CommonJS `require` won't provide type-checking.","wrong":"const JSONAPI = require('jsonapi-typescript');","symbol":"JSONAPI","correct":"import * as JSONAPI from 'jsonapi-typescript';"},{"note":"Specific types like `Document` are named exports. The package does not have a default export.","wrong":"import JSONAPI from 'jsonapi-typescript';","symbol":"Document","correct":"import { Document } from 'jsonapi-typescript';"},{"note":"Commonly used for defining the structure of individual resources within a JSON:API document.","symbol":"ResourceObject","correct":"import { ResourceObject } from 'jsonapi-typescript';"}],"quickstart":{"code":"import * as JSONAPI from 'jsonapi-typescript';\n\n// ✅ This should be OK (a valid single-resource JSON:API document)\nlet validDoc: JSONAPI.Document = {\n  data: {\n    type: 'articles',\n    id: '1',\n    attributes: {\n      title: 'Hello World'\n    },\n    relationships: {\n      author: {\n        data: { type: 'people', id: '9' }\n      }\n    }\n  }\n};\n\n// ⛔️ This should NOT be OK (missing 'data' or 'errors' top-level keys, 'result' is invalid)\n// let invalidDoc1: JSONAPI.Document = {\n//   result: \"Success!\"\n// };\n\n// ⛔️ This should NOT be OK (empty Array is not a valid JSON:API document root)\n// let invalidDoc2: JSONAPI.Document = [];\n\nconsole.log('Valid JSON:API document example:', JSON.stringify(validDoc, null, 2));\n","lang":"typescript","description":"Demonstrates importing the type definitions and validating a basic JSON:API document structure at compile-time."},"warnings":[{"fix":"Consider alternatives like `ts-japi` or `ts-json-api` for actively maintained and up-to-date JSON:API type solutions.","message":"The package appears to be abandoned, with no updates since April 2019. It may not be compatible with newer TypeScript versions (beyond TS 2.3 mentioned) or the latest JSON:API specification (v1.1 published July 2020).","severity":"breaking","affected_versions":"<=0.1.3"},{"fix":"Pair this with a separate JSON:API client or serialization library if runtime operations are needed. Or use a library that combines types with runtime logic.","message":"This package only provides type definitions; it does not include any runtime parsing, serialization, or client functionality. It's solely for compile-time validation.","severity":"gotcha","affected_versions":"*"},{"fix":"Manually extend or augment types if specific advanced JSON:API features not covered by this package are required.","message":"The type definitions might not fully encompass all optional or advanced features of the JSON:API specification (e.g., custom extensions, profiles) as the project predates later spec revisions.","severity":"gotcha","affected_versions":"<=0.1.3"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure the top-level document contains 'data', 'errors', or 'meta' members as per JSON:API specification.","cause":"Attempting to assign an object that does not conform to the JSON:API Document structure (e.g., using unknown top-level keys).","error":"Type '{ result: string; }' is not assignable to type 'Document'. Object literal may only specify known properties, and 'result' does not exist in type 'Document'."},{"fix":"Ensure that `data` and relationship `data` fields correctly specify `ResourceObject` or `ResourceIdentifierObject` types, or arrays thereof, as defined by JSON:API.","cause":"Assigning an incorrect type to a field expected to be a JSON:API primary data or relationship data (e.g., assigning a string where a ResourceObject is expected).","error":"Type 'string' is not assignable to type 'ResourceObject | ResourceObject[] | ResourceIdentifierObject | ResourceIdentifierObject[] | null | undefined'."},{"fix":"All `ResourceObject` and `ResourceIdentifierObject` types must include both `type` and `id` properties.","cause":"Creating a `ResourceObject` without the mandatory `id` property.","error":"Property 'id' is missing in type '{ type: \"articles\"; }' but required in type 'ResourceObject<any, object>'."}],"ecosystem":"npm"}