typescript-strict
БесплатноБез исполняемых скриптовНе проверенTypeScript strict mode patterns including schema-first development, branded types, type vs interface guidance, and tsconfig strict flags. Use when writing…
Об этом скилле
TypeScript Strict Mode
Core Rules
- Use
unknownat untrusted boundaries. Contain unavoidableanyin external declarations or interop shims and explain it - No type assertions (
as Type) without justification - Follow the repository's
type/interfaceconvention. Choose from language semantics when no convention exists - Derive a value set that already has an owner; never spell it a second time. Before writing a literal union, an enum list, or a
===/||chain over fixed values, search the codebase for that set — if a type, anas constlist, or a schema already declares it, derive from that one owner
Type vs Interface
type — unions, tuples, mapped types, and closed aliases
export type User = {
readonly id: string;
readonly email: string;
readonly name: string;
readonly roles: ReadonlyArray<string>;
};
Type aliases can name unions, intersections, tuples, primitives, mapped types, and object shapes. They cannot be reopened through declaration merging.
interface — extendable object contracts
export interface UserRepository {
findById(id: string): Promise<User | undefined>;
save(user: User): Promise<void>;
}
Interfaces describe object shapes, work with implements, extend with conflict checking, and support declaration merging. They are useful for behavior contracts and deliberately open extension points, but are not forbidden for data shapes.
Schema Duplication
Define a schema once per owned contract, version, and bounded context, then import it within that boundary. Do not couple independently deployed consumers or contexts merely because their fields happen to match today; validate and translate at each trust boundary, with contract tests where drift matters.
Inside one boundary this is a search, not a judgement call. When a compile-time
type and a runtime schema both need the same fixed set of values, one as const
list owns it and both derive from that list. If the set is already declared as a
hand-written union, widen that declaration and derive from it — do not leave a
second copy of the members behind in the schema.
// ✅ One owner; the type and the schema both derive from it
export const ORDER_STATES = ['draft', 'placed', 'shipped'] as const;
export type OrderState = (typeof ORDER_STATES)[number];
export const OrderStateSchema = z.enum(ORDER_STATES);
// ❌ Two owners for one set; they drift apart the first time a value is added
export type OrderState = 'draft' | 'placed' | 'shipped';
export const OrderStateSchema = z.enum(['draft', 'placed', 'shipped']);
// ✅ Define once for this API contract
export const CreateUserRequestSchema = z.object({
email: z.email(),
name: z.string().min(1),
});
export type CreateUserRequest = z.infer<typeof CreateUserRequestSchema>;
// Import and use wherever needed
Where schemas belong: validate at trust boundaries (HTTP handlers, queue consumers, file/env parsing, third-party API responses), then pass plain derived types through internal logic — internal functions trust their inputs. Prefer schema libraries implementing Standard Schema (Zod 4+, Valibot, ArkType) so validation tooling stays interchangeable.
Strict Mode Configuration
tsconfig.json Settings
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"noPropertyAccessFromIndexSignature": true,
"forceConsistentCasingInFileNames": true,
"allowUnusedLabels": false
}
}
What Each Setting Does
Strict baseline:
strict: true- Enables the strict type-checking family, includingnoImplicitAnyandstrictNullChecks
Additional project checks:
noUnusedLocals- Error on unused local variablesnoUnusedParameters- Error on unused function parametersnoImplicitReturns- Error when not all code paths return a valuenoFallthroughCasesInSwitch- Error on fallthrough cases in switch statements
Additional safety flags to assess against the codebase:
noUncheckedIndexedAccess- Array/object access returnsT | undefined(prevents runtime errors from assuming elements exist)exactOptionalPropertyTypes- Distinguishesproperty?: Tfromproperty: T | undefined(more precise types)noPropertyAccessFromIndexSignature- Requires bracket notation for index signature properties (forces awareness of dynamic access)forceConsistentCasingInFileNames- Prevents case sensitivity issues across operating systemsallowUnusedLabels- Error on unused labels (catches accidental labels that do nothing)
Additional Rules
- Prefer a justified, narrow `@ts-expect-e
Установить typescript-strict в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл typescript-strict?
TypeScript strict mode patterns including schema-first development, branded types, type vs interface guidance, and tsconfig strict flags. Use when writing TypeScript code, defining types or schemas, or reviewing type safety. For immutability and pure function patterns, see the functional skill.
Как установить скилл typescript-strict?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл typescript-strict запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic