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

typescript-best-practices

/typescript-best-practices

Przekształca typy TypeScript w wąskie, z uniami, pełnymi wariantami i flagami strict, gdy kod wymaga uporządkowania.

Repozytorium
dalcom-skills ↗
Licencja
Apache-2.0
Ostatnia zmiana repozytorium
10.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
2
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

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

Licencja

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

Co robi i kiedy

Przekształca typy TypeScript w wąskie, z uniami, pełnymi wariantami i flagami strict, gdy kod wymaga uporządkowania.

Oryginalny opis (EN)

Use when TypeScript needs shaping toward narrow types, unions, exhaustive variants, and strict flags. Not for error repair: use typescript-type-hardening. Not for non-TS domains: use type-driven.

Jak działa

  1. Read the scope first
  2. Turn on the strict set
  3. Shape the types toward narrow and explicit
  4. Validate every boundary and match the runtime
  5. Prove it with the compiler
  6. What you hand back
Sekcje z nagłówków SKILL.md, w oryginale · 59 linii, 596 słów
Podgląd SKILL.md
---
name: typescript-best-practices
description: 'Use when TypeScript needs shaping toward narrow types, unions, exhaustive variants, and strict flags. Not for error repair: use typescript-type-hardening. Not for non-TS domains: use type-driven.'
---

# TypeScript best practices

You shape TypeScript source proactively so bad states cannot be written: narrow types, discriminated unions, readonly where mutation is forbidden, validated boundaries, and the strict flags actually turned on. This is a shaping pass, not a repair job. A concrete error report (a message, a broken inference, a generic that will not constrain) belongs to typescript-type-hardening, and language-agnostic domain modeling belongs to type-driven.

This stays local and reversible: you touch only the in-scope TypeScript files and the named `tsconfig.json`, rolled back through version control. You never touch remote state.

What you need before starting: the in-scope TypeScript source files and the target `tsconfig.json`. The scope must name a proactive shaping pass. A concrete error report routes to typescript-type-hardening instead.

Limits that hold for the whole pass:

- No new `any`, `!` non-null assertions, or `as unknown as` double assertions.
- No invented strict flags beyond the TypeScript 7 set named below.
- No blanket ban on branded types or `as`. Use an opaque type where the domain identity invariant is real and enforced, and use `as` where TypeScript narrowing is insufficient, stating the reason each time.
- No unvalidated external shape shipped or re-exported without a validating boundary.

## Read the scope first

Read every in-scope file before changing any of them. You are done with this step when all of them have been read.

## Turn on the strict set

Check the project `tsconfig.json` for exactly this set and apply what is missing:

- `noUncheckedIndexedAccess`
- `exactOptionalPropertyTypes`
- `noImplicitOverride`
- `noFallthroughCasesInSwitch`
- `noPropertyAccessFromIndexSignature`
- `noImplicitReturns`
- `allowUnreachableCode: false`
- `verbatimModuleSyntax`
- `erasableSyntaxOnly`
- `isolatedDeclarations`

Use only these flags. If a check fails for a missing flag, the recovery is applying the named flag, with version control as the rollback.

## Shape the types toward narrow and explicit

Keep `unknown` only while it is genuinely opaque, and narrow it at trust boundaries with guards, predicates, or an explicit cast where narrowing is available. Model state machines and mutually exclusive variants as discriminated unions. Mark properties `readonly` where reassignment is forbidden. Add an opaque type for domain identity only where the invariant it models is real and enforced.

## Validate every boundary and match the runtime

Put a validating parser (Zod 4, Valibot, or ArkType through the Standard Schema interface) on every trust boundary where untrusted external input enters. Never widen or re-export an unvalidated external shape past that boundary. Set module resolution to `NodeNext` for Node.js targets and `ESNext` with a bundler for SPAs.

## Prove it with the compiler

Run `tsc --noEmit` and confirm it passes. Confirm the pass introduced no `any`, `!`, or `as unknown as`. Confirm every discriminated union is exhaustively checked through the compiler's switch and match checks, adding a final otherwise branch that narrows the unknown variant to `never` where the language lacks built-in exhaustiveness.

When this step fails, the cause is one of a short list. Report it plainly and stop rather than working around it:

- A type that cannot be narrowed: report it and stop. Do not widen scope or add a placeholder cast.
- A domain with no natural discriminant: propose a tag field, and stop if the domain does not support one. Do not force a union that does not fit.
- A validation library that is unavailable: state the missing constraint and stop. Do not ship the shape unvalidated.

## What you hand back

The shaped source and `tsconfig.json`, with a clean `tsc --noEmit` run as proof: illegal states unrepresentable, variants exhaustive, boundaries validated, and none of the refused constructs introduced.
Pliki w paczce (2)
  • SKILL.md 4 KB
  • agents/openai.yaml 1 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · gosuda/dalcom-skills90Apache-2.0
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 fea2f9e7c2ac (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-type-hardening
    Naprawia błędy typów i wnioskowania w TypeScript oraz mechanizmy typów: generyki, infer, mapped types i branded types.
  • 100typescript-patterns
    Podpowiada wzorce systemu typów TypeScript, typy narzędziowe i zasady trybu strict przy pisaniu i przeglądzie kodu.
  • 100typescript-strict
    Wprowadza konwencje ścisłego TypeScript: tryb strict, zakaz any, typy narzędziowe i obsługę błędów.
  • 95typescript-patterns
    Podaje wzorce TypeScript dla ścisłego, bezpiecznego typowo kodu: konfigurację kompilatora, typy z rozróżnialnymi wariantami, generyki i obsługę błędów.
  • 100developing-with-typescript
    Wspiera pisanie kodu w TypeScript 5.x: system typów, generyki, typy pomocnicze i tryb strict.
  • 90typescript-type-system
    Pomaga pracować z systemem typów TypeScript: tryb strict, złożone typy, generyki, type guards i konfiguracja kompilatora.

Uwagi i zgłoszenia

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