Skip to content
Back to skills

Typescript Style

ASecurity

Apply TypeScript style rules that prefer checked literal typing with satisfies and as const satisfies over unsafe assertions. Use when writing or reviewing TypeScript or TSX code, test fixtures, typed object literals, mocks, config objects, or table-driven cases.

  • 11 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
ai-agentstypescriptgoexpressapi

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add rootcastleco/rei-skills --skill typescript-style --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Typescript Style?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Typescript Style
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/rootcastleco-typescript-style/badge)](https://www.skillsdirectory.com/skills/rootcastleco-typescript-style)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: typescript-style
description: Apply TypeScript style rules that prefer checked literal typing with satisfies and as const satisfies over unsafe assertions. Use when writing or reviewing TypeScript or TSX code, test fixtures, typed object literals, mocks, config objects, or table-driven cases.
---

# TypeScript Style

## Prefer `satisfies` Over `as`

Avoid `as` type assertions and especially `as any`. Use `satisfies` when checking object literals, mocks, config objects, fixture data, and expected rows.

Bad:

```ts
const config = { port: 3000, host: 'localhost' } as ServerConfig;
const ctx = { fetchDirent: vi.fn(), addReadHistory: vi.fn() } as any;
```

Good:

```ts
const config = { port: 3000, host: 'localhost' } satisfies ServerConfig;
const ctx = { fetchDirent: vi.fn(), addReadHistory: vi.fn() } satisfies MockContext;
```

## Use `as const satisfies`

Use `as const satisfies` for static literal data when preserving exact literal values or readonly tuples helps TypeScript catch mistakes.

Good:

```ts
const ROUTES = {
	home: '/',
	about: '/about',
} as const satisfies Record<string, string>;
```

Good for table-driven cases:

```ts
const reportCases = [
	{ type: 'daily', period: '2026-05-16' },
	{ type: 'monthly', period: '2026-05' },
] as const satisfies readonly ReportCase[];
```

## Acceptable `as`

Use `as` only when `satisfies` cannot express the operation, such as narrowing data returned from an external untyped boundary or adapting to an API that requires a nominal type. Keep it local and avoid `as any`.

## Prefer `@ts-expect-error`

Use `@ts-expect-error` instead of `@ts-ignore`, and include a short explanation. `@ts-expect-error` fails when the underlying type error disappears, so stale suppressions are caught.

Bad:

```ts
// @ts-ignore
import privateApi from 'some-package/private-api';
```

Good:

```ts
// @ts-expect-error Private runtime API has no public type declaration.
import privateApi from 'some-package/private-api';
```

Files in this skill

  • LICENSE1.1 KB
  • SKILL.md1.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.