## 事象
[[Nuxt4]]のプロジェクトで[[tsconfig.json]]に [[vueCompilerOptions.strictTemplates]] を `true` に設定しても、存在しないテンプレートタグがエラーにならない。
[[tsconfig.json]]は以下。
```json
{
// https://nuxt.com/docs/guide/concepts/typescript
"files": [],
"references": [
{
"path": "./.nuxt/tsconfig.app.json"
},
{
"path": "./.nuxt/tsconfig.server.json"
},
{
"path": "./.nuxt/tsconfig.shared.json"
},
{
"path": "./.nuxt/tsconfig.node.json"
}
],
// これを追加
"vueCompilerOptions": {
"strictTemplates": true
}
}
```
このコードで `<Thanks />` がエラーにならない。
```html
<script setup lang="ts"></script>
<template>
<div>
<h1>Hello, World!</h1>
<Thanks />
</div>
</template>
```
### 環境
| 対象 | バージョン |
| -------------- | ------ |
| [[Nuxt]] | 4.2.2 |
| [[Vue]] | 3.5.25 |
| [[TypeScript]] | 5.9.3 |
## 原因
`tsconfig.json` の [[references (tsconfig)|references]] に記載されたプロジェクト([[tsconfig.json]])は、[[references (tsconfig)|references]]の元となっている `tsconfig.json` の設定を継承するわけではないから。
`tsconfig.json` の [[references (tsconfig)|references]] はプロジェクトの参照関係を示しているだけ。
## 解決方法
[[tsconfig.jsonに設定を追加 (Nuxt)|tsconfig.jsonに設定を追加]]する。
```ts
export default defineNuxtConfig({
typescript: {
tsConfig: {
vueCompilerOptions: {
strictTemplates: true,
},
},
},
});
```
## 関連
- [[📝shadcn-vueでtsconfig.jsonに記載した設定が有効にならない]]