Setting up TypeScript

TypeScriptのセットアップ

Sat Aug 03

Written by: Astro学習者

Astroのロゴ。

tutorial

If you do not already extend Astro’s strict or strictest recommended TypeScript settings in your tsconfig.json file, you may need to update your tsconfig.json to enable strictNullChecks.

tsconfig.jsonファイルにAstroのstrictまたはstrictest推奨のTypeScript設定をまだ拡張していない場合は、tsconfig.jsonを更新してstrictNullChecksを有効にする必要があるかもしれません。

{
  // Note: No change needed if you use "astro/tsconfigs/strict" or "astro/tsconfigs/strictest"
  "extends": "astro/tsconfigs/base",
  "compilerOptions": {
    "strictNullChecks": true
  }
}

If you use .js or .mjs files in an Astro project, you can enable IntelliSense and type checking in your editor by enabling allowJs in your tsconfig.json:

Astroプロジェクトで.jsまたは.mjsファイルを使用する場合、tsconfig.jsonallowJsを有効にすることで、インテリセンスとエディタでのタイプチェックを有効にすることができます:

{
  // Note: No change needed if you use "astro/tsconfigs/strict" or "astro/tsconfigs/strictest"
  "extends": "astro/tsconfigs/base",
  "compilerOptions": {
    "strictNullChecks": true,
    "allowJs": true
  }
}