feat: 위키 저장소 초기 커밋
- CLAUDE.md 운영 규칙 - wiki/ 정리된 지식 페이지 (Nuxt + Claude Code) - raw/ 원본 자료 - reference/ Nuxt 4.x 공식 문서 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
48
reference/6.bridge/2.typescript.md
Normal file
48
reference/6.bridge/2.typescript.md
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
title: TypeScript
|
||||
description: 'Learn how to use TypeScript with Nuxt Bridge.'
|
||||
---
|
||||
|
||||
## Remove Modules
|
||||
|
||||
- Remove `@nuxt/typescript-build`: Bridge enables same functionality
|
||||
- Remove `@nuxt/typescript-runtime` and `nuxt-ts`: Nuxt 2 has built-in runtime support
|
||||
|
||||
### Set `bridge.typescript`
|
||||
|
||||
```ts
|
||||
import { defineNuxtConfig } from '@nuxt/bridge'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
bridge: {
|
||||
typescript: true,
|
||||
nitro: false, // If migration to Nitro is complete, set to true
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
## Update `tsconfig.json`
|
||||
|
||||
If you are using TypeScript, you can edit your `tsconfig.json` to benefit from auto-generated Nuxt types:
|
||||
|
||||
```diff [tsconfig.json]
|
||||
{
|
||||
+ "extends": "./.nuxt/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
::note
|
||||
As `.nuxt/tsconfig.json` is generated and not checked into version control, you'll need to generate that file before running your tests. Add `nuxi prepare` as a step before your tests, otherwise you'll see `TS5083: Cannot read file '~/.nuxt/tsconfig.json'`
|
||||
|
||||
For modern Nuxt projects, we recommend using [TypeScript project references](/docs/4.x/directory-structure/tsconfig) instead of directly extending `.nuxt/tsconfig.json`.
|
||||
::
|
||||
|
||||
::note
|
||||
Keep in mind that all options extended from `./.nuxt/tsconfig.json` will be overwritten by the options defined in your `tsconfig.json`.
|
||||
Overwriting options such as `"compilerOptions.paths"` with your own configuration will lead TypeScript to not factor in the module resolutions from `./.nuxt/tsconfig.json`. This can lead to module resolutions such as `#imports` not being recognized.
|
||||
|
||||
In case you need to extend options provided by `./.nuxt/tsconfig.json` further, you can use the `alias` property within your `nuxt.config`. `nuxi` will pick them up and extend `./.nuxt/tsconfig.json` accordingly.
|
||||
::
|
||||
Reference in New Issue
Block a user