Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

typescript-best-practices

/typescript-best-practices

Modeluje typy w TypeScript: deklaracje, zawężanie danych z unknown, wycofywanie any i asercji oraz typowanie props i komponentów w plikach .tsx.

Repozytorium
agent-skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
09.11.2026

Ocena i bezpieczeństwo

90/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść25 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
10
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 09.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Modeluje typy w TypeScript: deklaracje, zawężanie danych z unknown, wycofywanie any i asercji oraz typowanie props i komponentów w plikach .tsx.

Oryginalny opis (EN)

TypeScript type modeling. Use when writing, changing, reviewing or refactoring TS code. Covers declaring types, narrowing boundary data from unknown, retiring any and assertions, expressing errors and domain concepts in types, choosing strictness, and typing Props / events / refs and generic components in .tsx. Does not cover JS style, module layout, JSX rendering, tsconfig or lint config.

Jak działa

  1. How to write
  2. Read on demand
  3. When the user has to decide
Sekcje z nagłówków SKILL.md, w oryginale · 43 linii, 563 słów
Podgląd SKILL.md
---
name: typescript-best-practices
description: TypeScript type modeling. Use when writing, changing, reviewing or refactoring TS code. Covers declaring types, narrowing boundary data from unknown, retiring any and assertions, expressing errors and domain concepts in types, choosing strictness, and typing Props / events / refs and generic components in .tsx. Does not cover JS style, module layout, JSX rendering, tsconfig or lint config.
---

# TypeScript best practices

Every rule here rests on a criterion: when it applies, what signal says the code went wrong, and how to fix it. Before writing, read the project as it stands — `tsconfig` strictness, naming style, how `interface` and `type` are used, the type directory and path aliases. When the project already has a convention, follow it; this skill only fills the gaps.

## How to write

- Object shapes use `interface`; unions, intersections, mapped and conditional types use `type`. Object contracts, including ones derived from a schema, take the `I` prefix, `enum` takes `E`, and unions, utility types and key types take no prefix.
- External data starts as `unknown` and narrows through a type guard; no `any`, no `!`, no `@ts-ignore`.
- Exported functions state their return type. Types and value definitions belonging to this module (`interface`, `type`, `enum`, `as const` value tables) go into `xxx.type.ts` by default, and do not need two call sites before they earn their own file. `declare` and third-party augmentations go into `xxx.d.ts`; functions and classes stay in the implementation file.
- Adding types does not move business logic and does not add dependencies. When the project has no `strict`, keep to strict style in the files this change touches.
- In a `.tsx` file, only types are in scope: Props, events, refs, generic components. Component boundaries, state, Hooks, Effects and render behavior belong elsewhere.
- Do not upgrade rule sets on your own, change `tsconfig` strictness, or reshuffle type files in bulk; those ripple through the whole codebase.

## Read on demand

Write to the rules above first. Look up the matching document when a specific question comes up, and check the cases when a business tradeoff is involved.

### Everyday writing

| Task | File |
| --- | --- |
| How to declare a type, where it lives, domain concepts, how far to take generics and utility types | [type-modeling.md](references/type-modeling.md) |
| Moving off `any`, narrowing `unknown`, assertions and fallback branches, errors and async failures | [type-safety.md](references/type-safety.md) |
| Type naming, `import type` and `export type`, class member modifiers and function parameters | [naming-and-declaration.md](references/naming-and-declaration.md) |
| Typing component Props, events, refs and generic components in `.tsx` | [jsx-types.md](references/jsx-types.md) |

### Business cases

| Task | File |
| --- | --- |
| The whole path from an API response as `unknown` to a domain object | [api-response.md](references/patterns/api-response.md) |
| Modeling order and workflow states with the transitions they allow | [state-machine.md](references/patterns/state-machine.md) |
| Narrowing `any` in a legacy module field by field, without growing the diff | [legacy-any.md](references/patterns/legacy-any.md) |
| Writing config objects and constant tables with `satisfies` | [config-object.md](references/patterns/config-object.md) |

## When the user has to decide

- Read `skill-memory/typescript-best-practices.md` first; a recorded answer is followed without asking again.
- What to ask: how far to tighten strictness, how much of the legacy `any` to narrow, whether types deserve their own file, whether an inheritance chain should be split.
- Ask only when the answer changes code in more than one place; write the conclusion and one line of reasoning into that file afterwards, not the conversation.
- Everything else follows the code as it is: naming, whether a local type gets extracted, whether a particular `as` stays, and the decisions the project already made, such as an existing type file or an enum already in use.
Pliki w paczce (10)
  • SKILL.md 4 KB
  • agents/openai.yaml 1 KB
  • references/jsx-types.md 3 KB
  • references/naming-and-declaration.md 3 KB
  • references/type-modeling.md 7 KB
  • references/type-safety.md 4 KB
  • references/patterns/api-response.md 3 KB
  • references/patterns/config-object.md 2 KB
  • references/patterns/legacy-any.md 3 KB
  • references/patterns/state-machine.md 2 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · zn-craft/agent-skills90MIT
seaworld008/commonly-used-high-value-skills100MIT
HoangNguyen0403/agent-skills-standard100MIT
overextended/skills100GPL-3.0
alleneubank/claude-code100Apache-2.0
VdustR/vp-claude-code-marketplace100MIT
fcakyon/claude-codex-settings91Apache-2.0
workerstack/clients91MIT
itsvedantkumar/vstack91MIT

Migawka bazy z 13.11.2026 · wersja paczki 713be5f251d4 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100typescript-react-patterns
    Stosuje dobre praktyki TypeScript w React: typowanie komponentów, hooków, zdarzeń, refów i komponentów generycznych oraz naprawianie błędów typów.
  • 90fe-typescript
    Pisze i przegląda TypeScript w aplikacjach front-end: ścisła konfiguracja, typy na granicach API, pamięci i formularzy oraz zawężanie zamiast rzutowania.
  • 100typescript
    Pomaga pisać i naprawiać typy TypeScript: modelowanie danych z generykami, unionami i branded types, błędy zawężania oraz konfigurację tsconfig i narzędzi builda.
  • 91typescript-forms
    Stosuje w plikach TypeScript wzorce unii dyskryminowanych, typów brandowanych, unknown zamiast any oraz walidację przez schematy na granicach.
  • 100typescript-type-safety
    Pilnuje bezpieczeństwa typów w TypeScript: różnica unknown i any, zawężanie null, unie dyskryminowane i typy błędów.
  • 100react-best-practices
    Stosuje dobre praktyki przy czytaniu i pisaniu komponentów React w plikach .tsx i .jsx z importami React.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.