agentsclimarketplace

Ts language patterns

Skill fusengine/agents/plugins/typescript-expert/skills/ts-language-patterns

Use when: writing or reviewing modern TypeScript syntax and idioms — const type parameters, using / await using resource management, standard ECMAScript decorators, satisfies, or fixing LLM-authored anti-patterns (legacy enum/namespace, missing import type). Covers TS 6.0 language features and inference. Do NOT use for: tsconfig / compiler flags (use ts-config), SOLID structure and file-size rules (use solid-generic), or framework-specific APIs.From its SKILL.md

Install
npx -y skills add fusengine/agents --skill ts-language-patterns

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 22 stars22 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

4.5 KB, 963 tokens by cl100k_base, as published. Nobody here has run it

TypeScript Language Patterns (TS 6.0)

Agent Workflow (MANDATORY)

Before writing non-trivial TypeScript, use TeamCreate to spawn 3 agents:

  1. fuse-ai-pilot:explore-codebase - Detect existing idioms, verbatimModuleSyntax, tsconfig
  2. fuse-ai-pilot:research-expert - Verify current syntax on typescriptlang.org
  3. mcp__context7__query-docs - /microsoft/typescript for exact API shapes

After writing, run fuse-ai-pilot:sniper for validation.


Overview

FeatureWhat it gives you
const type parameters<const T> infers the narrowest literal type without as const at call sites
using / await usingDeterministic cleanup via Symbol.dispose / Symbol.asyncDispose
Standard decoratorsECMAScript decorators — NOT experimentalDecorators
satisfiesValidate a value against a type while keeping its narrow inferred type
6.0 inferenceMethod-syntax callbacks are no longer contextually sensitive → order-independent inference

Critical Rules

  1. import type is mandatory under verbatimModuleSyntax - type-only imports must say type, or emit/stripping breaks.
  2. No legacy enum - prefer const objects as const; enum is un-erasable by Node's type stripper.
  3. No namespace with runtime code - use ESM modules; type-only namespace is acceptable.
  4. Use standard decorators - never enable experimentalDecorators for new code.
  5. Never rely on implicit any - strict is the 6.0 default; annotate or infer explicitly.

Reference Guide

Concepts

TopicReferenceWhen to Consult
Resource managementresource-management.mdLoad when using using / await using / disposables
Generics & inferencegenerics-and-inference.mdLoad when using const type params, satisfies, or debugging inference
Decoratorsdecorators.mdLoad when adding decorators
LLM pitfallsllm-pitfalls.mdLoad when reviewing or migrating legacy/AI-authored TypeScript

Templates

TemplateWhen to Use
modern-patterns.mdCopy-paste const/satisfies/decorator examples
resource-management.mdCopy-paste using / DisposableStack examples

Quick Reference

const type parameter

function first<const T extends readonly unknown[]>(arr: T): T[0] {
  return arr[0];
}
const x = first(["a", "b"]); // x: "a"  (literal, no `as const` needed)

using for deterministic cleanup

function openFile(path: string) {
  const handle = acquire(path);
  return { handle, [Symbol.dispose]() { release(handle); } };
}
{
  using file = openFile("./data"); // released automatically at block end
}

satisfies

const config = {
  port: 3000,
  host: "localhost",
} satisfies Record<string, string | number>;
// config.port stays `number`, not widened to `string | number`

Best Practices

DO

  • Replace enum Color { Red } with const Color = { Red: "red" } as const
  • Reach for using over manual try/finally cleanup when a resource has a disposer
  • Use satisfies instead of a type annotation when you want to keep the narrow inferred type

DON'T

  • Write import { SomeType } for a type-only import — use import type { SomeType }
  • Enable experimentalDecorators or emitDecoratorMetadata for new code
  • Use namespace to organize runtime code — that is what ESM modules are for

What ships with it: 7 files

14.4 KB alongside SKILL.md

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.