Skip to content
Back to skills

Typescript Strict

ASecurity

Strict TypeScript practices. Use when writing TypeScript code to ensure type safety.

  • 20 stars
  • 0 votes
  • 0 copies
  • 20 views
  • Added February 7, 2026
developmenttypescriptapi

Works with

  • api

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add oro-ad/nuxt-claude-devtools --skill typescript-strict --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Typescript Strict?

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

Security grade badge for Typescript Strict
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/oro-ad-typescript-strict/badge)](https://www.skillsdirectory.com/skills/oro-ad-typescript-strict)

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-strict
description: Strict TypeScript practices. Use when writing TypeScript code to ensure type safety.
---

Enforce strict TypeScript practices:

## No `any`

Never use `any`. Use `unknown` for truly unknown types:

```typescript
// ❌ Avoid
function process(data: any) { }

// ✅ Better
function process(data: unknown) {
  if (typeof data === 'string') {
    // Now TypeScript knows it's a string
  }
}
```

## Explicit Return Types

Add explicit return types for public/exported functions:

```typescript
// ✅ Explicit return type
function calculateTotal(items: Item[]): number {
  return items.reduce((sum, item) => sum + item.price, 0)
}

// ✅ For async functions
async function fetchUser(id: string): Promise<User | null> {
  // ...
}
```

## Interface over Type

Prefer `interface` for object shapes (better error messages, extendable):

```typescript
// ✅ Prefer interface
interface User {
  id: string
  name: string
  email: string
}

// Use type for unions, primitives, or complex types
type Status = 'pending' | 'active' | 'done'
type Nullable<T> = T | null
```

## Readonly

Mark immutable data as `readonly`:

```typescript
interface Config {
  readonly apiUrl: string
  readonly maxRetries: number
}

function processItems(items: readonly Item[]) {
  // items.push() would be an error
}
```

## Type Guards

Use type guards for runtime type checking:

```typescript
function isUser(value: unknown): value is User {
  return (
    typeof value === 'object' &&
    value !== null &&
    'id' in value &&
    'name' in value
  )
}

if (isUser(data)) {
  // TypeScript knows data is User
  console.log(data.name)
}
```

## Const Assertions

Use `as const` for literal types:

```typescript
const STATUSES = ['pending', 'active', 'done'] as const
type Status = typeof STATUSES[number] // 'pending' | 'active' | 'done'
```

## Non-null Assertion

Avoid `!` when possible. Use optional chaining or type guards:

```typescript
// ❌ Risky
const name = user!.name

// ✅ Safer
const name = user?.name ?? 'Unknown'
```

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 development →

Comments

Loading comments…

Newsletter

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