feat: skill expansion — browser, security, SQL, files (16 skills total)
Novas skills instaladas: - openclaw-agent-browser v1.0.0 CLI Chromium — navegação, login, screenshots, state - skill-security-audit v1.0.0 SAST scanning, prompt injection, secrets audit - sql-toolkit v1.0.0 PostgreSQL/MySQL/SQLite — schema, query, otimização - file v1.0.0 Organização de arquivos por contexto - file-summary v1.0.0 Extração e resumo de PDFs, Word, Excel Workspace expandido: - TOOLS.md: +Browser automation, Security audit, SQL, File management - AGENTS.md: +Linux Analyst section (comandos, logs, rede, scripts) + Full-stack strategy - MEMORY.md: 16 skills indexadas, stack map, comandos Linux ref - SESSION-STATE.md: atualizado com contexto completo - lock.json: sincronizado com 16 skills instaladas
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"version": 1,
|
||||
"registry": "https://clawhub.ai",
|
||||
"slug": "typescript",
|
||||
"installedVersion": "1.0.2",
|
||||
"installedAt": 1779234199574,
|
||||
"fingerprint": "9c948b42fc4b93fa1062c3e16d1a28715b78afc4860ef5418947c86d8b72253d"
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
name: TypeScript
|
||||
slug: typescript
|
||||
version: 1.0.2
|
||||
description: Write type-safe TypeScript with proper narrowing, inference patterns, and strict mode best practices.
|
||||
---
|
||||
|
||||
## When to Use
|
||||
|
||||
User needs TypeScript expertise — from basic typing to advanced generics. Agent handles type narrowing, inference, discriminated unions, and strict mode patterns.
|
||||
|
||||
## Quick Reference
|
||||
|
||||
| Topic | File |
|
||||
|-------|------|
|
||||
| Generic patterns | `generics.md` |
|
||||
| Utility types | `utility-types.md` |
|
||||
| Declaration files | `declarations.md` |
|
||||
| Migration from JS | `migration.md` |
|
||||
|
||||
## Stop Using `any`
|
||||
|
||||
- `unknown` forces you to narrow before use — `any` silently breaks type safety
|
||||
- API responses: type them or use `unknown`, never `any`
|
||||
- When you don't know the type, that's `unknown`, not `any`
|
||||
|
||||
## Narrowing Failures
|
||||
|
||||
- `filter(Boolean)` doesn't narrow — use `.filter((x): x is T => Boolean(x))`
|
||||
- `Object.keys(obj)` returns `string[]`, not `keyof typeof obj` — intentional, objects can have extra keys
|
||||
- `Array.isArray()` narrows to `any[]` — may need assertion for element type
|
||||
- `in` operator narrows but only if property is in exactly one branch of union
|
||||
|
||||
## Literal Type Traps
|
||||
|
||||
- `let x = "hello"` is `string` — use `const` or `as const` for literal type
|
||||
- Object properties widen: `{ status: "ok" }` has `status: string` — use `as const` or type annotation
|
||||
- Function return types widen — annotate explicitly for literal returns
|
||||
|
||||
## Inference Limits
|
||||
|
||||
- Callbacks lose inference in some array methods — annotate parameter when TS guesses wrong
|
||||
- Generic functions need usage to infer — `fn<T>()` can't infer, pass a value or annotate
|
||||
- Nested generics often fail — break into steps with explicit types
|
||||
|
||||
## Discriminated Unions
|
||||
|
||||
- Add a literal `type` or `kind` field to each variant — enables exhaustive switch
|
||||
- Exhaustive check: `default: const _never: never = x` — compile error if case missed
|
||||
- Don't mix discriminated with optional properties — breaks narrowing
|
||||
|
||||
## `satisfies` vs Type Annotation
|
||||
|
||||
- `const x: Type = val` widens to Type — loses literal info
|
||||
- `const x = val satisfies Type` keeps literal, checks compatibility — prefer for config objects
|
||||
|
||||
## Strict Null Handling
|
||||
|
||||
- Optional chaining `?.` returns `undefined`, not `null` — matters for APIs expecting `null`
|
||||
- `??` only catches `null`/`undefined` — `||` catches all falsy including `0` and `""`
|
||||
- Non-null `!` should be last resort — prefer narrowing or early return
|
||||
|
||||
## Module Boundaries
|
||||
|
||||
- `import type` for type-only imports — stripped at runtime, avoids bundler issues
|
||||
- Re-exporting types: `export type { X }` — prevents accidental runtime dependency
|
||||
- `.d.ts` augmentation: use `declare module` with exact module path
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ownerId": "kn73vp5rarc3b14rc7wjcw8f8580t5d1",
|
||||
"slug": "typescript",
|
||||
"version": "1.0.2",
|
||||
"publishedAt": 1771105330227
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
# Declaration File Traps
|
||||
|
||||
- `declare module "x"` requiere path EXACTO — `"lodash"` ≠ `"lodash/index"`
|
||||
- Augmentation sin imports se vuelve global — añadir `export {}` para forzar módulo
|
||||
- `declare const` sin valor crea global — puede colisionar
|
||||
- `declare function` en módulo no es global — necesita `declare global {}`
|
||||
- Archivos .d.ts sin import/export son scripts globales — legacy confuso
|
||||
- `interface` se puede merge desde otros archivos — `type` no
|
||||
- `paths` en tsconfig solo compilación — bundler necesita config separada
|
||||
- `baseUrl` requerido para `paths` — fácil de olvidar
|
||||
- `export default` en .d.ts problemático — preferir named exports
|
||||
- `declare module "*.svg"` afecta TODOS los .svg — no tipos específicos
|
||||
@@ -0,0 +1,13 @@
|
||||
# Generic Traps
|
||||
|
||||
- `useState<User>()` infiere `User | undefined` — manejar undefined inicial
|
||||
- `Array.filter(x => x.active)` no narrowea — necesita type guard: `.filter((x): x is Active => x.active)`
|
||||
- `Promise.all([a(), b()])` infiere tupla solo con `as const`
|
||||
- `<T = any>` escapa el `any` al resto del código
|
||||
- `<T extends object>` permite arrays — usar `Record<string, unknown>` para objetos
|
||||
- `<T extends string>` con literal infiere `string`, no el literal
|
||||
- `keyof T` en función genérica es `string | number | symbol`
|
||||
- Arrays covariantes — `Dog[]` assignable a `Animal[]` pero push de Cat rompe runtime
|
||||
- Function params contravariantes — `(Animal) => void` NO assignable a `(Dog) => void`
|
||||
- `{ [K in keyof T]: X }` pierde modificadores — usar `-?` o `-readonly`
|
||||
- `Partial<T>` y `Required<T>` son shallow — no afectan nested
|
||||
@@ -0,0 +1,15 @@
|
||||
# Migration Traps
|
||||
|
||||
- `noImplicitAny: false` esconde errores — código "compila" pero tipos wrong
|
||||
- Callback params sin tipo son `any` silencioso — `arr.map(x => x.foo)` no falla
|
||||
- `strictNullChecks: true` rompe mucho — localStorage.getItem devuelve `string | null`
|
||||
- `strictPropertyInitialization` requiere init en constructor — o usar `!`
|
||||
- `as Type` no valida nada — `"hello" as number` compila
|
||||
- `as unknown as Type` escape total — evitar
|
||||
- JSON.parse devuelve `any` — necesita assertion o validación
|
||||
- `@types/x` puede estar desactualizado vs el paquete
|
||||
- `skipLibCheck: true` esconde errores en tus .d.ts también
|
||||
- `import x from "cjs"` vs `import * as x from "cjs"` — diferente comportamiento
|
||||
- `// @ts-ignore` se propaga — usar `@ts-expect-error` que falla si no hay error
|
||||
- `any` temporal se queda para siempre — mejor `unknown` desde el inicio
|
||||
- `outDir` no limpia archivos viejos — .js huérfanos causan bugs
|
||||
@@ -0,0 +1,13 @@
|
||||
# Utility Type Traps
|
||||
|
||||
- `Partial<T>` es shallow — nested siguen required
|
||||
- `Required<T>` no quita `undefined` del union — sigue teniendo undefined
|
||||
- `Omit<T, K>` no verifica que K existe — `Omit<User, "typo">` compila
|
||||
- `Pick` con key inexistente también compila — sin validación
|
||||
- `Record<string, T>` implica TODA key existe — acceso a inexistente devuelve T, no T|undefined
|
||||
- `Record<K, V>` con K union no garantiza todas las keys
|
||||
- `Extract<T, U>` devuelve `never` si no match — silenciosamente vacío
|
||||
- `ReturnType<typeof fn>` con overload toma solo última signature
|
||||
- `Parameters` igual con overloads — inconsistente
|
||||
- `NonNullable<T>` quita null Y undefined — a veces solo quieres uno
|
||||
- `Awaited<T>` unwrapea recursivamente — sorpresa con Promise<Promise<T>>
|
||||
Reference in New Issue
Block a user