Skip to content

disjukr/jtc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JTC Logo

VS Code Marketplace Open VSX

JTC (JSON/YAML Type Checker)

JTC validates json, jsonc, and yaml documents against TypeScript types using a $type field.

How It Works

  1. Write $type in your document (example: "./types.ts#MyType").
  2. JTC parses the document into an internal rough JSON structure.
  3. JTC runs TypeScript diagnostics for that value against the target type.
  4. Diagnostics are shown directly in VS Code.

$type itself is treated as metadata and excluded from type checking.

Example

VSCode Demo

{
  "$type": "./types.ts#User",
  "name": "Alice",
  "age": 20
}

./types.ts

export interface User {
  name: string;
  age: number;
}

If a value has the wrong type, JTC reports a diagnostic at the corresponding JSON/YAML path.

Monorepo Structure

  • json-type-checker: core library (@disjukr/jtc)
  • jtc-cli: CLI (jtc)
  • jtc-vscode: VS Code extension

Development

Prerequisites:

  • Deno
  • VS Code (or compatible)

Build extension bundle:

cd jtc-vscode
deno task build

Watch mode:

cd jtc-vscode
deno task watch

Run extension dev host:

  • Use the Extension launch configuration from .vscode/launch.json.

Install CLI globally:

cd jtc-cli
deno task install-cli

Use CLI:

jtc --help