jpskill.com
🛠️ 開発・MCP コミュニティ

shared-tooling-typescript-config

TypeScriptの厳格な設定や最新オプション、パスエイリアスの同期、特殊な設定などを扱い、TypeScriptプロジェクトの構成を効率化し、保守性を高めるSkill。

📜 元の英語説明(参考)

TypeScript strict mode configs, TS 5.x+ options (verbatimModuleSyntax, module preserve, moduleDetection force, configDir), path alias sync, specialized configs

🇯🇵 日本人クリエイター向け解説

一言でいうと

TypeScriptの厳格な設定や最新オプション、パスエイリアスの同期、特殊な設定などを扱い、TypeScriptプロジェクトの構成を効率化し、保守性を高めるSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o shared-tooling-typescript-config.zip https://jpskill.com/download/10269.zip && unzip -o shared-tooling-typescript-config.zip && rm shared-tooling-typescript-config.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10269.zip -OutFile "$d\shared-tooling-typescript-config.zip"; Expand-Archive "$d\shared-tooling-typescript-config.zip" -DestinationPath $d -Force; ri "$d\shared-tooling-typescript-config.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して shared-tooling-typescript-config.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → shared-tooling-typescript-config フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

TypeScript 設定パターン

クイックガイド: packages/typescript-config/ に共有 TypeScript strict 設定を置きます。strict: true に加えて noUncheckedIndexedAccessexactOptionalPropertyTypesnoImplicitOverride を有効にします。最新のモジュール設定を使用します: module: "preserve"moduleResolution: "bundler"verbatimModuleSyntax: truemoduleDetection: "force"。ポータブルなパスのために ${configDir} (TS 5.5+) を使用します。tsconfig とビルドツールの間でパスエイリアスを同期します。


<critical_requirements>

重要: この Skill を使用する前に

すべてのコードは CLAUDE.md のプロジェクト規約に従う必要があります (kebab-case、名前付きエクスポート、インポート順序、import type、名前付き定数)

(すべての tsconfig.json ファイルで TypeScript strict モード (strict: true) を有効にする必要があります - 必須)

(明示的な import type を強制するために verbatimModuleSyntax: true を使用する必要があります - 非推奨の importsNotUsedAsValues を置き換えます)

(monorepo では共有設定パターン (packages/typescript-config/) を使用する必要があります - パッケージごとに設定を複製しないでください)

(tsconfig.json とビルドツールの間でパスエイリアスを同期する必要があります - 不一致はインポート解決の失敗を引き起こします)

(バンドラーベースのプロジェクトでは、最新のモジュール設定を使用する必要があります: module: "preserve"moduleResolution: "bundler" )

</critical_requirements>


自動検出: TypeScript config, tsconfig.json, tsconfig, strict mode, noUncheckedIndexedAccess, exactOptionalPropertyTypes, verbatimModuleSyntax, moduleDetection force, module preserve, moduleResolution bundler, configDir, path aliases, typescript-config, shared config, noImplicitOverride, isolatedDeclarations, erasableSyntaxOnly, import defer

使用する場面:

  • 新規または既存のプロジェクトで TypeScript strict モードを設定する
  • monorepo の一貫性のために共有 tsconfig パターンを作成する
  • TS 5.x+ の最新のモジュール設定 (preserve, bundler, verbatimModuleSyntax) を構成する
  • tsconfig とビルドツールの間でパスエイリアスを同期する
  • 特殊な設定 (React、Node.js、ライブラリ公開) を作成する
  • 非推奨の TypeScript オプションから移行する
  • 新しい TS 機能 (isolatedDeclarationserasableSyntaxOnlyconfigDirimport defer) を評価する

使用しない場面:

  • ランタイム TypeScript コードパターン (language/framework skills を参照)
  • リンター設定 (別の skill)
  • ビルドツール設定 (別の skill) - ただし、パスエイリアスの同期に関するガイダンスはここに残してください
  • 命名やインポートなどの日常的なコーディング規約 (CLAUDE.md を参照)

カバーする主なパターン:

  • monorepo 拡張パターンを持つ共有 strict 設定ベース
  • 最新のモジュール設定 (TS 5.x+: preserve, bundler, verbatimModuleSyntax, moduleDetection)
  • ポータブルな共有設定のための ${configDir} テンプレート変数 (TS 5.5+)
  • tsconfig とビルドツール間のパスエイリアス同期
  • 特殊な設定 (react.json, node.json, library.json)
  • 並列ビルドサポートのための isolatedDeclarations (TS 5.5+)
  • Node.js 直接実行のための erasableSyntaxOnly (TS 5.8+)
  • 遅延モジュール評価のための import defer (TS 5.9+)
  • TypeScript 6.0 の新しいデフォルトと非推奨

詳細なリソース:

  • examples/core.md - 完全な設定例、特殊な設定、TS 5.x+ の機能
  • reference.md - 意思決定フレームワーク、アンチパターン、落とし穴

<philosophy>

Philosophy

TypeScript の設定は、デフォルトで strict であり、パッケージ間で共有され、前方互換性がある べきです。すべてのプロジェクトは、最も strict な設定から始まります。共有設定はドリフトを防ぎます。最新のモジュール設定は、バンドラーベースのワークフローと一致します。

コア原則:

  1. デフォルトで Strict - strict: true に加えて noUncheckedIndexedAccessexactOptionalPropertyTypesnoImplicitOverride
  2. 共有し、複製しない - Monorepo 設定は共有ベースを拡張します。スタンドアロンプロジェクトは同じ strict オプションを使用します
  3. 最新のモジュールモード - バンドラープロジェクトの場合は module: "preserve" + moduleResolution: "bundler"。Node.js の場合は "node18"/"node20"
  4. パスエイリアスのパリティ - エイリアスは tsconfig とビルドツールの両方に存在する必要があります

</philosophy>


<patterns>

コアパターン

パターン 1: 共有 Strict 設定ベース

すべてのアプリとパッケージは、共有の strict ベースを拡張します。ベース設定は packages/typescript-config/ (monorepo) に存在するか、スタンドアロンプロジェクトにインライン化されます。

// packages/typescript-config/base.json (省略)
{
  "compilerOptions": {
    "strict": true,
    "exactOptionalPropertyTypes": true,
    "noUncheckedIndexedAccess": true,
    "noImplicitOverride": true,
    "module": "preserve",
    "moduleResolution": "bundler",
    "verbatimModuleSyntax": true
  }
}

コンシューマー設定は共有ベースを拡張し、異なるもののみを追加します (例: paths)。

良い理由: strict 設定の単一の信頼できる情報源、すべてのパッケージが同じ安全性の保証を得る、コンシューマーは異なるもののみを追加する

完全なベース設定、コンシューマー設定、および特殊な設定 (react.json, node.json, library.json) については、examples/core.md を参照してください。


パターン 2: 最新のモジュール設定 (TS 5.x+)

verbatimModuleSyntax (TS 5.0+)

型のみのインポートに対して明示的な import type を強制します。非推奨の importsNotUsedAsValues および preserveValueImports を置き換えます。

// verbatimModuleSyntax: true の場合

// 良い - 明示的な型インポート
import type { User } from "./types";
import { createUser } from "./api";

// 悪い - 値としてインポートされた型 (verbatimModuleSyntax でエラー)
import { User, createUser } from "./api";

module: "preserve" (TS 5.4+)

import/export 構文をそのまま保持します。TypeScript は型チェックのみを行います。バンドラーがモジュール出力を処理します。

使用する場面: TypeScript が JavaScript を出力しないバンドラーベースのプロジェクト (noEmit: true)

使用しない場面: CJS/ESM を直接出力する Node.js パッケージ -- 代わりに module: "node18" または "node20" を使用してください

moduleDetection: "force" (TS 5.0+)

import/export がなくても、すべてのファイルをモジュールとして扱うように強制します。予期しないグローバルスコープの汚染を防ぎます。


パターン 3: ${config

(原文はここで途切れています)

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

TypeScript Configuration Patterns

Quick Guide: Shared TypeScript strict config in packages/typescript-config/. Enable strict: true plus noUncheckedIndexedAccess, exactOptionalPropertyTypes, noImplicitOverride. Use modern module settings: module: "preserve", moduleResolution: "bundler", verbatimModuleSyntax: true, moduleDetection: "force". Use ${configDir} (TS 5.5+) for portable paths. Sync path aliases between tsconfig and your build tool.


<critical_requirements>

CRITICAL: Before Using This Skill

All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering, import type, named constants)

(You MUST enable TypeScript strict mode (strict: true) in ALL tsconfig.json files - non-negotiable)

(You MUST use verbatimModuleSyntax: true to enforce explicit import type - replaces deprecated importsNotUsedAsValues)

(You MUST use shared config pattern (packages/typescript-config/) in monorepos - never duplicate configs per package)

(You MUST sync path aliases between tsconfig.json and your build tool - mismatches cause import resolution failures)

(You MUST use modern module settings: module: "preserve", moduleResolution: "bundler" for bundler-based projects)

</critical_requirements>


Auto-detection: TypeScript config, tsconfig.json, tsconfig, strict mode, noUncheckedIndexedAccess, exactOptionalPropertyTypes, verbatimModuleSyntax, moduleDetection force, module preserve, moduleResolution bundler, configDir, path aliases, typescript-config, shared config, noImplicitOverride, isolatedDeclarations, erasableSyntaxOnly, import defer

When to use:

  • Setting up TypeScript strict mode in new or existing projects
  • Creating shared tsconfig patterns for monorepo consistency
  • Configuring TS 5.x+ modern module settings (preserve, bundler, verbatimModuleSyntax)
  • Syncing path aliases between tsconfig and your build tool
  • Creating specialized configs (React, Node.js, library publishing)
  • Migrating from deprecated TypeScript options
  • Evaluating new TS features (isolatedDeclarations, erasableSyntaxOnly, configDir, import defer)

When NOT to use:

  • Runtime TypeScript code patterns (see language/framework skills)
  • Linter configuration (separate skill)
  • Build tool configuration (separate skill) - but DO keep path alias sync guidance here
  • Daily coding conventions like naming and imports (see CLAUDE.md)

Key patterns covered:

  • Shared strict config base with monorepo extension pattern
  • Modern module settings (TS 5.x+: preserve, bundler, verbatimModuleSyntax, moduleDetection)
  • ${configDir} template variable for portable shared configs (TS 5.5+)
  • Path alias sync between tsconfig and build tools
  • Specialized configs (react.json, node.json, library.json)
  • isolatedDeclarations for parallel build support (TS 5.5+)
  • erasableSyntaxOnly for Node.js direct execution (TS 5.8+)
  • import defer for deferred module evaluation (TS 5.9+)
  • TypeScript 6.0 new defaults and deprecations

Detailed resources:


<philosophy>

Philosophy

TypeScript configuration should be strict by default, shared across packages, and forward-compatible. Every project starts with the strictest settings. Shared configs prevent drift. Modern module settings align with bundler-based workflows.

Core principles:

  1. Strict by default - strict: true plus noUncheckedIndexedAccess, exactOptionalPropertyTypes, noImplicitOverride
  2. Share, don't duplicate - Monorepo configs extend a shared base; standalone projects use the same strict options
  3. Modern module mode - module: "preserve" + moduleResolution: "bundler" for bundler projects; "node18"/"node20" for Node.js
  4. Path alias parity - Aliases must exist in both tsconfig AND the build tool

</philosophy>


<patterns>

Core Patterns

Pattern 1: Shared Strict Config Base

All apps and packages extend a shared strict base. The base config lives in packages/typescript-config/ (monorepo) or is inlined in a standalone project.

// packages/typescript-config/base.json (abbreviated)
{
  "compilerOptions": {
    "strict": true,
    "exactOptionalPropertyTypes": true,
    "noUncheckedIndexedAccess": true,
    "noImplicitOverride": true,
    "module": "preserve",
    "moduleResolution": "bundler",
    "verbatimModuleSyntax": true
  }
}

Consumer configs extend the shared base and only add what differs (e.g. paths).

Why good: Single source of truth for strict settings, all packages get the same safety guarantees, consumers only add what differs

See examples/core.md for full base config, consumer configs, and specialized configs (react.json, node.json, library.json).


Pattern 2: Modern Module Settings (TS 5.x+)

verbatimModuleSyntax (TS 5.0+)

Enforces explicit import type for type-only imports. Replaces deprecated importsNotUsedAsValues and preserveValueImports.

// With verbatimModuleSyntax: true

// Good - explicit type import
import type { User } from "./types";
import { createUser } from "./api";

// Bad - type imported as value (errors with verbatimModuleSyntax)
import { User, createUser } from "./api";

module: "preserve" (TS 5.4+)

Preserves import/export syntax as-is. TypeScript only type-checks; the bundler handles module output.

When to use: Bundler-based projects where TypeScript does NOT emit JavaScript (noEmit: true)

When not to use: Node.js packages that emit CJS/ESM directly -- use module: "node18" or "node20" instead

moduleDetection: "force" (TS 5.0+)

Forces all files to be treated as modules, even without import/export. Prevents unexpected global scope pollution.


Pattern 3: ${configDir} Template Variable (TS 5.5+)

Makes shared configs portable. ${configDir} resolves to the directory of the leaf config (the one that extends), not the base.

// packages/typescript-config/base.json
{
  "compilerOptions": {
    "outDir": "${configDir}/dist",
    "rootDir": "${configDir}/src"
  },
  "include": ["${configDir}/src"]
}

Why good: Consumers don't need to override outDir, rootDir, or include -- paths resolve relative to their own directory

Gotcha: Without ${configDir}, relative paths like "./dist" resolve from the base config's location (packages/typescript-config/), not the consuming package.


Pattern 4: Path Alias Sync

Path aliases must be configured in BOTH tsconfig.json AND your build tool. A mismatch causes either TypeScript errors or build-time import resolution failures.

// tsconfig.json -- paths here for TypeScript type checking
{ "compilerOptions": { "paths": { "@/*": ["./src/*"] } } }

// Build tool config -- SAME aliases for bundler resolution
// resolve: { alias: { "@": path.resolve(__dirname, "./src") } }

Gotcha: Forgetting to sync causes "module not found" errors. TypeScript resolves fine but the bundler fails (or vice versa). When adding a new alias, always update BOTH files.

See examples/core.md for full tsconfig + build tool config examples.


Pattern 5: isolatedDeclarations (TS 5.5+)

Requires explicit type annotations on all exports. Enables parallel .d.ts generation by external tools (oxc, swc).

// With isolatedDeclarations: true

// Good - explicit return type on export
export function getUser(id: string): User {
  return { id, name: "John" };
}

// Bad - inferred return type (will error)
export function getUser(id: string) {
  return { id, name: "John" };
}

When to use: Large monorepos publishing library packages where parallel .d.ts generation speeds up builds

When not to use: Application code that is never consumed as a library (adds verbosity for no benefit)


Pattern 6: erasableSyntaxOnly (TS 5.8+)

Prohibits TypeScript-specific constructs that have runtime behavior (enums, namespaces, parameter properties). Ensures compatibility with Node.js --experimental-strip-types for direct TS execution.

Blocked constructs: enum, const enum, runtime namespace, parameter properties (constructor(public name: string))

Allowed constructs: type, interface, type-only imports -- anything that can be erased without changing runtime behavior

When to use: Projects using Node.js direct TS execution, or targeting the types-only philosophy

When not to use: Projects that rely heavily on enums, namespaces, or parameter properties

See examples/core.md for full good/bad code examples.


Pattern 7: import defer (TS 5.9+)

Deferred module evaluation -- the module loads but doesn't execute until an export is accessed. Only works with namespace imports under --module preserve or esnext.

import * as analytics from "./heavy-analytics.js";

// Module is loaded but NOT executed yet
if (needsAnalytics) {
  analytics.track("event"); // Module executes here on first access
}

When to use: Improving startup performance for conditionally-loaded heavy modules

Limitation: Named imports and default imports are not supported with import defer -- only namespace syntax (import defer * as ...)


Pattern 8: TypeScript 6.0 New Defaults

TS 6.0 (February 2026) changes several defaults. If your config already follows the patterns above, most changes are transparent.

Option Old Default TS 6.0 Default
strict false true
module commonjs esnext
target es3 es2025
rootDir inferred . (current dir)
types auto-discover @types/* [] (explicit only)
noUncheckedSideEffectImports false true
libReplacement true false

Action required: Set "types": ["node"] (or relevant packages) explicitly after upgrading to TS 6.0 -- the auto-discovery of @types/* is gone.

Deprecated in TS 6.0 (removed in TS 7.0):

  • target: "es5", moduleResolution: "node" (node10), module: "amd"|"umd"|"systemjs"|"none"
  • esModuleInterop: false, --baseUrl as module resolution root, --outFile

Use "ignoreDeprecations": "6.0" during migration to suppress warnings.

See examples/core.md for full TS 6.0 defaults table and deprecation details.


Pattern 9: NoInfer<T> Utility Type (TS 5.4+)

Prevents TypeScript from inferring a type from a specific position in generic functions.

// Good - NoInfer ensures initial must be from states array
declare function createFSM<TState extends string>(config: {
  initial: NoInfer<TState>;
  states: TState[];
}): void;

createFSM({
  initial: "invalid", // Error: "invalid" not in states
  states: ["open", "closed"],
});

Why good: TypeScript infers TState from states only; initial must match without widening the union

When to use: Generic functions where one parameter should constrain another, not expand the inferred type

</patterns>


<decision_framework>

Decision Framework

Module Settings Selection

What module/moduleResolution to use?
├─ Bundler-based project (TypeScript does NOT emit JS)?
│   └─ YES -> module: "preserve", moduleResolution: "bundler"
├─ Node.js package (direct execution)?
│   ├─ Node 20+? -> module: "node20" (TS 5.9+, stable)
│   └─ Node 18+? -> module: "node18" (TS 5.8+)
└─ Library consumed by both bundlers and Node?
    └─ module: "nodenext" (most compatible)

Target Selection

What target to use?
├─ Bundler-based project? -> target: "ES2022" (stable, well-supported)
├─ Node.js 18+? -> target: "ES2022"
├─ Node.js 20+? -> target: "ES2023"
└─ TS 6.0+ project? -> target: "es2025" (new default)

New Feature Adoption

isolatedDeclarations?
├─ Publishing library packages in large monorepo? -> Enable
├─ Application code only? -> Skip (adds verbosity for no benefit)
└─ Using oxc or swc for builds? -> Enable (these tools benefit most)

erasableSyntaxOnly?
├─ Using Node.js --experimental-strip-types? -> Enable (required)
├─ Project uses enums extensively? -> Skip (migration cost too high)
└─ Standard bundler project? -> Optional (nice-to-have)

See reference.md for additional decision frameworks (shared vs local config, TS 6.0 migration).

</decision_framework>


<red_flags>

RED FLAGS

High Priority Issues:

  • Disabling TypeScript strict mode (strict: false) -- allows implicit any and null bugs across the project
  • Missing verbatimModuleSyntax: true -- type imports may or may not be elided depending on transpiler
  • Not using shared configs in monorepo -- configs drift, creating inconsistent safety levels across packages
  • Using deprecated importsNotUsedAsValues or preserveValueImports -- replaced by verbatimModuleSyntax since TS 5.0

Medium Priority Issues:

  • Path aliases in tsconfig but not in build tool (or vice versa) -- causes import resolution failures
  • Using deprecated moduleResolution: "node" (node10) instead of "bundler" or "node18" -- deprecated in TS 6.0
  • Using deprecated target: "ES3" or "ES5" -- deprecated in TS 6.0, removed in TS 7.0
  • Duplicated config per package instead of extending shared base

Gotchas & Edge Cases:

  • ${configDir} resolves to the directory of the leaf config (the one that uses extends), not the base config
  • verbatimModuleSyntax requires ALL type-only imports to use import type -- mixed imports like import { Type, value } error if Type is type-only. Use inline syntax: import { type Type, value }
  • exactOptionalPropertyTypes means { key?: string } does NOT accept { key: undefined } -- only omission or string
  • noUncheckedIndexedAccess adds | undefined to ALL index signatures, including arrays -- use for...of or guard with if
  • module: "preserve" only works with noEmit: true or emitDeclarationOnly: true
  • TS 6.0 changes types default to [] -- @types/node, @types/react etc. must be explicitly listed after upgrade
  • import defer only supports namespace syntax (import defer * as ...), not named or default imports

</red_flags>


<critical_reminders>

CRITICAL REMINDERS

All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering, import type, named constants)

(You MUST enable TypeScript strict mode (strict: true) in ALL tsconfig.json files - non-negotiable)

(You MUST use verbatimModuleSyntax: true to enforce explicit import type - replaces deprecated importsNotUsedAsValues)

(You MUST use shared config pattern (packages/typescript-config/) in monorepos - never duplicate configs per package)

(You MUST sync path aliases between tsconfig.json and your build tool - mismatches cause import resolution failures)

(You MUST use modern module settings: module: "preserve", moduleResolution: "bundler" for bundler-based projects)

Failure to follow these rules will cause type-safety gaps, inconsistent configs, and import resolution failures.

</critical_reminders>