mcpField
T
ts-check-jsdoc-experiment

ts-check-jsdoc-experiment

github.com/marius-townhouseDevelopment643 installsUpdated 38w ago
Repository

About ts-check-jsdoc-experiment

A coding skill for adding TypeScript checks to JavaScript with `@ts-check` and JSDoc, without converting files. It supports gradual migration, experimentation, and type validation.

Key features

  1. 01Type-check JavaScript with `@ts-check`
  2. 02Add types through JSDoc annotations
  3. 03Adopt TypeScript checks incrementally

Use cases

  1. 01Experiment with TypeScript in a JavaScript file
  2. 02Gradually migrate a JavaScript codebase
  3. 03Validate JavaScript with type annotations

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/marius-townhouse/effective-typescript-skills --skill ts-check-jsdoc-experiment

After installing, type/ts-check-jsdoc-experimentin Claude Code to confirm it loaded.

Details

From the project README

Use @ts-check and JSDoc to Experiment with TypeScript

Overview

You can add TypeScript type checking to JavaScript files without converting them to TypeScript. Use @ts-check at the top of a JS file and JSDoc annotations to add types. This lets you experiment with TypeScript gradually without committing to the full conversion.

When to Use This Skill

  • Experimenting with TypeScript
  • Gradually migrating JavaScript
  • Adding types to JS files
  • Teams learning TypeScript
  • Validating JavaScript with types

The Iron Rule

Use @ts-check and JSDoc to add TypeScript checking to JavaScript files without full conversion.

Example

// @ts-check

/**
 * @param {string} name
 * @param {number} age
 * @returns {string}
 */
function greet(name, age) {
  return `Hello ${name}, you are ${age}`;
}

greet('Alice', 30); // OK
greet('Alice', '30'); // Type error!

/** @type {string[]} */
const names = ['Alice', 'Bob'];

/** @typedef {{ x: number, y: number }} Point */
/** @type {Point} */
const point = { x: 1, y: 2 };

Reference

  • Effective TypeScript, 2nd Edition by Dan Vanderkam
  • Item 80: Use @ts-check and JSDoc to Experiment with TypeScript

Comments

Markdown supported