udaysharmadev/gravitas

gravitas-typescript

GRAVITAS extension for TypeScript projects.

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/udaysharmadev/gravitas --skill gravitas-typescript

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

GRAVITAS — TypeScript Extension

Extends the base GRAVITAS skill with TypeScript-specific patterns. Load skills/gravitas/SKILL.md first, then this file.


TypeScript Recon Additions

Add to standard recon checklist:

□ tsconfig.json — strict mode? noUncheckedIndexedAccess? exactOptionalPropertyTypes?
□ package.json — TypeScript version, test runner (vitest vs jest)
□ eslint config — @typescript-eslint rules in effect
□ type declarations — are there .d.ts files that affect this module?
□ path aliases — does tsconfig have paths? (affects imports)

Read tsconfig strictly

bash
cat tsconfig.json | jq '.compilerOptions | {strict, noUncheckedIndexedAccess, exactOptionalPropertyTypes, target, lib}'

TypeScript Verification Chain

bash
# Full chain — always in this order
tsc --noEmit                           # catches type errors first
eslint . --max-warnings 0              # @typescript-eslint rules
vitest run --reporter=verbose          # or: jest --verbose

# With coverage
vitest run --coverage --reporter=verbose

# Type coverage (optional, requires type-coverage)
npx type-coverage --strict

TypeScript-Specific Anti-Patterns

Never use any

typescript
BAD:  function process(data: any) { ... }
GOOD: function process(data: ProcessInput) { ... }

Never use as to silence type errors

typescript
BAD:  const user = data as User;  // silences real type error
GOOD: if (isUser(data)) { const user = data; ... }

Handle undefined explicitly

typescript
BAD:  const name = user.name;          // may be undefined
GOOD: const name = user.name ?? 'Anonymous';

Strict null checks

typescript
BAD:  return users.find(u => u.id === id).name;  // crash if not found
GOOD: return users.find(u => u.id === id)?.name;

Common TypeScript Failure Modes

FailureRoot CauseFix
Object is possibly undefinedOptional property accessed without guardAdd ?. or null check
Type 'string' is not assignable to 'number'Wrong type passedCheck function signature, fix caller
Property does not exist on typeInterface mismatchUpdate interface or use correct property
Cannot find modulePath alias not in tsconfigAdd to paths in tsconfig
Argument of type X is not assignable to YGeneric type mismatchCheck generic constraints
Implicit any in strict modeMissing type annotationAdd explicit type

TypeScript Patterns

Parameterized types over any

typescript
function first<T>(arr: T[]): T | undefined {
  return arr[0];
}

Discriminated unions for type safety

typescript
type Result<T> =
  | { ok: true; data: T }
  | { ok: false; error: string };

Type guards instead of casts

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

Test Patterns (Vitest)

Test file location

Follow project convention — check existing tests:

bash
find src/ -name "*.test.ts" | head -5  # see the pattern

Standard test structure

typescript
import { describe, it, expect, vi, beforeEach } from 'vitest';

describe('[module]', () => {
  beforeEach(() => { vi.clearAllMocks(); });

  it('[behavior] when [condition]', () => {
    // Arrange
    const input = ...;
    // Act
    const result = fn(input);
    // Assert
    expect(result).toEqual(expected);
  });
});

Mocking

typescript
vi.mock('../db', () => ({
  query: vi.fn().mockResolvedValue({ rows: [] })
}));

Quick Reference

bash
# Find all TypeScript errors
tsc --noEmit 2>&1 | grep "error TS"

# Find implicit any
tsc --noEmit --strict 2>&1

# Count test files
find src/ -name "*.test.ts" | wc -l

# Run single test file
vitest run src/auth/session.test.ts

# Watch mode (dev)
vitest --watch

관련 작업

같은 저장소의 Skills

더 많은 Skills

모든 Skills