본문으로 건너뛰기
Skillpedia
일반 코딩7.8k · #13084

typescript-compile-check-resilient

하는 일

이 스킬은 TypeScript 컴파일러를 직접 실행하고, 방금 만들었거나 수정한 파일의 오류만 보여 주는 방법을 설명합니다. 오래된 오류가 있는 큰 TypeScript 프로젝트에서 일하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓프로젝트 환경에서 npx나 TypeScript 명령이 실패할 때.
  • ✓프로젝트에 내 변경과 무관한 오래된 타입 오류가 이미 있을 때.
  • ✓새로 만든 파일만 깔끔하게 컴파일되는지 확인하고 싶을 때.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/typescript-compile-check-resilient/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/typescript-compile-check-resilient/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“방금 쓴 파일이 컴파일되는지 확인해 주실 수 있나요? 프로젝트의 나머지 오래된 오류는 무시해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 TypeScript 컴파일러를 Node 파일로 직접 실행한 다음, 출력을 걸러 새 파일이나 변경된 파일의 오류만 보여 줍니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

TypeScript Compile-Check (Resilient) with File-Scoped Error Filtering

Use this workflow when you need to validate TypeScript changes in a project but the standard npx tsc or node_modules/.bin/tsc invocations fail due to broken symlinks, missing PATH entries, or environment issues.


When to Use This Skill

  • npx tsc fails with "command not found" or permission errors
  • node_modules/.bin/tsc symlink is broken or unresolvable
  • You need to validate only newly-created or task-specific files without being blocked by pre-existing compile errors in the broader codebase

Step 1 — Invoke tsc Directly via node_modules

Bypass npx and symlinks entirely by calling the TypeScript binary directly:

node_modules/typescript/bin/tsc --noEmit 2>&1; echo EXIT:$?

Why this works: The tsc CLI entry point is a plain Node.js script at node_modules/typescript/bin/tsc. It does not depend on symlinks or PATH resolution. The --noEmit flag checks types without writing output files. Capturing EXIT:$? lets you programmatically detect success (EXIT:0) vs failure (EXIT:1 or higher).

If the project uses a custom tsconfig, specify it explicitly:

node_modules/typescript/bin/tsc --noEmit --project tsconfig.json 2>&1; echo EXIT:$?

Step 2 — Filter Output to Task-Specific Files Only

When a legacy codebase has pre-existing errors, the full tsc output will be noisy and may cause false negatives. Pipe through grep to isolate errors from only the files you created or modified:

node_modules/typescript/bin/tsc --noEmit 2>&1 \
  | grep -E "(file-pattern)" ; echo EXIT:${PIPESTATUS[0]}

Examples

Single new file:

node_modules/typescript/bin/tsc --noEmit 2>&1 \
  | grep -E "settings-store\.ts"

Multiple new files (pipe-delimited pattern):

node_modules/typescript/bin/tsc --noEmit 2>&1 \
  | grep -E "(settings-keys|settings-store|preferences|SettingsModal)"

All files in a specific directory:

node_modules/typescript/bin/tsc --noEmit 2>&1 \
  | grep -E "src/features/my-feature/"

Check: no output = no errors in your files (success).


Step 3 — Capture Exit Code Correctly Through a Pipe

When grepping, the shell exit code reflects grep, not tsc. Use ${PIPESTATUS[0]} (bash) to recover the original tsc exit code:

node_modules/typescript/bin/tsc --noEmit 2>&1 \
  | grep -E "(my-file-pattern)"; echo "TSC_EXIT:${PIPESTATUS[0]}"

Or store errors explicitly:

TSC_OUTPUT=$(node_modules/typescript/bin/tsc --noEmit 2>&1)
TSC_EXIT=$?
echo "$TSC_OUTPUT" | grep -E "(settings-keys|settings-store|preferences|SettingsModal)"
echo "TSC_EXIT:$TSC_EXIT"

The second approach (storing output in a variable) is the most reliable since $? is captured before the pipe.


Step 4 — Interpret Results

Condition Meaning
TSC_EXIT:0, no grep output ✅ Full project clean, your files are fine
TSC_EXIT:1, no grep output ✅ Your files are fine; pre-existing errors elsewhere (acceptable)
TSC_EXIT:1, grep output present ❌ Your files have errors — fix them
TSC_EXIT:2 ❌ tsc configuration error (bad tsconfig, missing typescript package)

Fallback: Verify TypeScript Is Installed

If node_modules/typescript/bin/tsc does not exist:

# Check if typescript is installed
ls node_modules/typescript/bin/tsc 2>/dev/null || echo "TypeScript not installed"

# Install if needed
npm install --save-dev typescript
# or
yarn add --dev typescript

Full Example

# Store full tsc output and exit code
TSC_OUTPUT=$(node_modules/typescript/bin/tsc --noEmit 2>&1)
TSC_EXIT=$?

# Show only errors in newly-created files
NEW_FILE_ERRORS=$(echo "$TSC_OUTPUT" | grep -E "(settings-keys|settings-store|preferences|SettingsModal)")

if [ -z "$NEW_FILE_ERRORS" ]; then
  echo "✅ No TypeScript errors in new files (TSC_EXIT:$TSC_EXIT)"
else
  echo "❌ TypeScript errors in new files:"
  echo "$NEW_FILE_ERRORS"
  exit 1
fi

Notes

  • This technique is safe for CI and local environments alike.
  • The direct node_modules/typescript/bin/tsc path works on macOS, Linux, and Windows (via node node_modules/typescript/bin/tsc on Windows CMD).
  • On Windows, replace the bash script with: node node_modules/typescript/bin/tsc --noEmit
  • Always prefer --noEmit for validation-only checks to avoid side effects.
자주 묻는 질문

컴파일러를 직접 실행하는 이유는 무엇인가요?

일반 명령을 깨뜨릴 수 있는 링크와 명령 경로 문제를 피하기 위해서입니다.

특정 설정 파일을 쓸 수 있나요?

네. 검사가 프로젝트 설정 파일을 가리켜 올바른 옵션을 사용하도록 할 수 있습니다.

검사가 통과했는지 어떻게 알 수 있나요?

명령은 종료 코드를 출력하며, 오류가 없으면 0입니다.

상세 정보

작성자의 원본 설명

TypeScript compile-checking in projects where npx and node_modules/.bin symlinks fail, with a filtering technique to isolate errors from only newly-created or task-specific files — ignoring pre-existing legacy errors.

repo: HKUDS/AgentPilot

인기도

GitHub 스타
7.8k
순위
#13084
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬