JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q33567F
  • License MIT

CLI tool to statically type-check JavaScript via JSDoc annotations

Package Exports

  • jstype-cli
  • jstype-cli/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jstype-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JSType CLI

JSType is a lightweight type checker for JavaScript, designed to help you catch type errors without switching to TypeScript. It scans your JavaScript files for inline JSDoc comment type annotations and verifies that variable values match their declared types.

Features

  • 📝 Non-intrusive type checking - Uses inline JSDoc comment syntax for declaring types.
  • 🔄 No build step required - Just install and link the CLI tool (no need to change file extensions or refactor code).
  • Gradual adoption - Adopt type checking in stages. You can apply types to entire files or parts of files (great for legacy projects).
  • Performance-Oriented - Includes support for skipping entire files or file segments with special comments.
  • 🔍 Rich type support - Handles primitive types, arrays, unions, and more.

Installation

Global Install

npm install -g jstype-cli

Local Development / Testing

git clone https://github.com/your-username/JSType.git
cd JSType
npm install
npm link

Usage

Basic Usage

jstype path/to/your/file.js

With Verbose Output

jstype path/to/your/file.js --verbose

Type Annotations

JSType uses inline comment annotations to specify types:

// Basic types
/** @type {string} */
let name = "Alice"; // ✅ No error

/** @type {number} */
let age = "twenty"; // ❌ Type mismatch error

/** @type {boolean} */
let isValid = "true"; // ❌ Type mismatch error (string, not boolean)

/** @type {array} */
let arr = [1, 2, 3]; // ✅ Matches array type

// Type checking in assignments
/** @type {number} */
let count = 5; // ✅ Matches number type

/** @type {string} */
count = "10"; // ❌ Cannot reassign type

count = "ten"; // ❌ Type mismatch error in assignment

Supported Types

  • Primitive types: string, number, boolean, null, undefined
  • Complex types: object, array, function
  • Array types: type[] (e.g., string[], number[])
  • Union types: type1|type2 (e.g., string|number)

Results Reported

JSType provides clear error messages when type mismatches are detected:

Error example

image

Success example

image

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Roadmap

  • Add type check for function variables
  • Add type check for component props
  • Add type check for local imports
  • Convert to package so it can be installed globally with npm
  • Memory Management - garbage colleting