DEV Community

Cover image for Schema-DTS: Linked Data Types & Code Generation

Posted on

Schema-DTS: Linked Data Types & Code Generation

Schema-DTS is a Google Open Source Initiative project that makes it possible to write JSON-LD literals in the vocabulary.

GitHub logo google / schema-dts

JSON-LD TypeScript types for vocabulary

Build Status Coverage Status schema-dts npm version schema-dts-gen version


JSON-LD TypeScript types for vocabulary.

schema-dts provides TypeScript definitions for vocabulary in JSON-LD format. The typings are exposed as complete sets of discriminated type unions, allowing for easy completions and stricter validation.

Example of Code Completion using schema-dts

This repository contains two NPM packages:

  • schema-dts-gen Providing a command-line tool to generate TypeScript files based on a specific Schema version and layer.
  • schema-dts Pre-packaged TypeScript typings of latest schema, without pending and other non-core layers.

Note: This is not an officially supported Google product.


To use the typings for your project, simply add the schema-dts NPM package to your project:

npm install schema-dts

Then you can use it by importing "schema-dts".

Root context

You will usually want your top-level item to include a @context, like In order for your object type to accept this property, you can augment it with WithContext, e.g.:

import { Person, WithContext

It consists of two NPM packages:

  1. schema-dts - A set of default types and properties representing, including deprecated types, pending types, and certain extension vocabularies.

  2. schema-dts-gen - A CLI that dynamically generates TypeScript definitions given a layer (e.g. "schema" or "all layers") with custom flags and configuration (e.g. a custom "@context", skipping deprecated types and properties, etc.).

Top comments (0)