with one click
typescript-strict
Enforce TypeScript strict mode and type safety. Use when setting up projects, reviewing code, or when type errors are ignored. Covers strict flags, no-any rules, and type inference best practices.
Menu
Enforce TypeScript strict mode and type safety. Use when setting up projects, reviewing code, or when type errors are ignored. Covers strict flags, no-any rules, and type inference best practices.
| name | typescript-strict |
| description | Enforce TypeScript strict mode and type safety. Use when setting up projects, reviewing code, or when type errors are ignored. Covers strict flags, no-any rules, and type inference best practices. |
| allowed-tools | Read, Glob, Grep, Edit, Write, Bash |
| license | MIT |
| metadata | {"author":"antigravity-team","version":"1.0"} |
TypeScript 엄격 모드와 타입 안전성을 강제하는 스킬입니다.
TypeScript 5.x에서 strict 모드가 새 프로젝트의 기본값으로 권장됨 "any 사용은 TypeScript를 쓰는 의미를 없앤다"
| 규칙 | 상태 | 설명 |
|---|---|---|
strict: true | 🔴 필수 | 모든 엄격 검사 활성화 |
any 금지 | 🔴 필수 | unknown 또는 제네릭 사용 |
// @ts-ignore 금지 | 🔴 필수 | 타입 에러 해결 필수 |
as 캐스팅 최소화 | 🟡 권장 | 타입 가드 우선 |
{
"compilerOptions": {
// 🔴 필수: strict 플래그
"strict": true,
// strict가 포함하는 옵션들 (개별 비활성화 금지)
// "strictNullChecks": true,
// "strictFunctionTypes": true,
// "strictBindCallApply": true,
// "strictPropertyInitialization": true,
// "noImplicitAny": true,
// "noImplicitThis": true,
// "alwaysStrict": true,
// 🔴 추가 필수 옵션
"noUncheckedIndexedAccess": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
// 🟡 권장 옵션
"exactOptionalPropertyTypes": true,
"noPropertyAccessFromIndexSignature": true
}
}
// ❌ BAD: any 사용
function processData(data: any) {
return data.value; // 런타임 에러 가능
}
const result: any = fetchData();
result.nonExistent(); // 컴파일 통과, 런타임 에러
// ✅ GOOD: unknown + 타입 가드
function processData(data: unknown) {
if (isValidData(data)) {
return data.value;
}
throw new Error('Invalid data');
}
function isValidData(data: unknown): data is { value: string } {
return typeof data === 'object'
&& data !== null
&& 'value' in data;
}
// ✅ GOOD: 제네릭 사용
function processData<T extends { value: string }>(data: T) {
return data.value;
}
// Before
function parse(json: string): any {
return JSON.parse(json);
}
// After
function parse(json: string): unknown {
return JSON.parse(json);
}
// 사용 시 타입 체크 필요
const result = parse('{"name": "test"}');
if (isUser(result)) {
console.log(result.name); // 안전
}
// ❌ BAD: 위험한 타입 단언
const user = response.data as User;
user.name.toUpperCase(); // null이면 에러
// ❌ BAD: 이중 단언 (매우 위험)
const value = data as unknown as TargetType;
// ✅ GOOD: 타입 가드
function isUser(data: unknown): data is User {
return (
typeof data === 'object' &&
data !== null &&
'name' in data &&
typeof (data as { name: unknown }).name === 'string'
);
}
if (isUser(response.data)) {
response.data.name.toUpperCase(); // 안전
}
// ✅ GOOD: Zod 스키마 검증
import { z } from 'zod';
const UserSchema = z.object({
name: z.string(),
email: z.string().email(),
});
const user = UserSchema.parse(response.data);
// ❌ BAD: null 체크 없음
function getLength(str: string | null) {
return str.length; // 에러: null일 수 있음
}
// ✅ GOOD: null 체크
function getLength(str: string | null) {
if (str === null) return 0;
return str.length;
}
// ✅ GOOD: 옵셔널 체이닝
function getLength(str: string | null) {
return str?.length ?? 0;
}
// noUncheckedIndexedAccess: true 일 때
const arr = [1, 2, 3];
const first = arr[0]; // number | undefined
// ❌ BAD: undefined 체크 없음
console.log(first.toFixed(2)); // 에러
// ✅ GOOD: undefined 체크
if (first !== undefined) {
console.log(first.toFixed(2));
}
// ✅ GOOD: 논리 연산자
console.log(arr[0]?.toFixed(2) ?? 'N/A');
// ❌ BAD: 반환 타입 추론 의존
function fetchUser(id: string) {
return api.get(`/users/${id}`); // 반환 타입?
}
// ✅ GOOD: 명시적 반환 타입
async function fetchUser(id: string): Promise<User> {
return api.get(`/users/${id}`);
}
// ✅ GOOD: 오버로드로 정확한 타입
function process(input: string): string;
function process(input: number): number;
function process(input: string | number): string | number {
if (typeof input === 'string') {
return input.toUpperCase();
}
return input * 2;
}
const str = process('hello'); // string
const num = process(42); // number
// ❌ BAD: any 사용
function first(arr: any[]): any {
return arr[0];
}
// ✅ GOOD: 제네릭
function first<T>(arr: T[]): T | undefined {
return arr[0];
}
// ✅ GOOD: 제약 있는 제네릭
function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] {
return obj[key];
}
{
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"rules": {
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unsafe-assignment": "error",
"@typescript-eslint/no-unsafe-member-access": "error",
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/no-unsafe-return": "error",
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/prefer-nullish-coalescing": "warn"
}
}
// 🔴 절대 금지
// @ts-ignore
// @ts-nocheck
// @ts-expect-error (테스트 제외)
// eslint-disable @typescript-eslint/no-explicit-any
// 🔴 금지: any 캐스팅
data as any
(data as unknown) as TargetType
// 🟡 최소화
data! // non-null assertion
data as Type // 타입 가드 우선
# TypeScript 초기화
npx tsc --init
# strict 활성화 확인
grep -n "strict" tsconfig.json
# 1. strict 활성화
# tsconfig.json: "strict": true
# 2. 에러 확인
npx tsc --noEmit
# 3. 점진적 수정
# - any → unknown
# - as → 타입 가드
# - null 체크 추가
타입 안전성 체크:
- [ ] any 사용하지 않음
- [ ] @ts-ignore 없음
- [ ] 타입 단언 최소화
- [ ] null 체크 적절함
strict: true 설정noUncheckedIndexedAccess: true 설정Professional frontend standards for building, scaffolding, extending, or reviewing any UI or frontend project — new or existing — even when standards aren't explicitly asked for. Keeps generated code consistent, reusable, secure, and production-quality. Framework-agnostic: React, Vue, Angular, Svelte, plain JS.
发布本地生成的 HTML、Markdown、TXT、PDF、Word 或 PPTX 到 ShareOne 平台,生成公网分享短链接;或者当用户提供 ShareOne 链接并要求下载文件、修改文件、拉取/处理评论时使用此技能。当用户要求“发布”、“分享”、“生成链接”、“上线”,或者“下载这个链接的文件”、“修改这个 ShareOne 链接的内容”、“拉取这个链接的评论”时,必须使用此技能。
Generate AI chat completions using GPT-4o through the verging.ai proxy API with streaming (SSE) and non-streaming response support.
Convert text to speech audio using OpenAI TTS-1-HD through the verging.ai proxy API. Supports multiple voices, playback speed control, and various audio output formats.
Generate AI images using DALL-E 3 or gpt-image-1 through the verging.ai proxy API. Supports standard and HD quality, multiple images per request, and returns CDN-hosted image URLs.
Analyze images using GPT-4o Vision through the verging.ai proxy API, supporting both image URL (JSON) and file upload (multipart) modes.