Next.js에서 Typescript를 도입 할 때 특히 아무것도하지 않아도된다는 이야기
3244 단어 ReactTypeScriptnext.js
개요
Next.js 진짜로 친절, Typescript 도입에 무엇인가 특히 하는 일 없어서 이야기입니다
Next.js에서 Typescript를 도입 할 때
create-next-app
에서 Next.js 프로젝트를 만듭니다.
> npx create-next-app
그때 생성된 프로젝트에는 Typescript는 포함되어 있지 않습니다.
package.json{
"name": "hoge",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "10.1.2",
"react": "17.0.2",
"react-dom": "17.0.2"
}
}
Typescript를 설치합니다.
> yarn add --dev typescript @types/react @types/node
이제 yarn run dev
를 실행합니다.
그러면 아래와 같은 로그가 표시됩니다.
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Using webpack 4. Reason: future.webpack5 option not enabled https://nextjs.org/docs/messages/webpack5
We detected TypeScript in your project and created a tsconfig.json file for you.
We detected TypeScript in your project and created a tsconfig.json file for you.
Typescript가 있는 것을 찾았으니까, tsconfig.json 만들었어, 라고 하는 것이군요.
진짜 친절.
이제 기본 index.js
을 index.tsx
로 변경해도 제대로 작동합니다.
Reference
이 문제에 관하여(Next.js에서 Typescript를 도입 할 때 특히 아무것도하지 않아도된다는 이야기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/toshiokun/items/7b019a3aea6a54ff401e
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
create-next-app
에서 Next.js 프로젝트를 만듭니다.> npx create-next-app
그때 생성된 프로젝트에는 Typescript는 포함되어 있지 않습니다.
package.json
{
"name": "hoge",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "10.1.2",
"react": "17.0.2",
"react-dom": "17.0.2"
}
}
Typescript를 설치합니다.
> yarn add --dev typescript @types/react @types/node
이제
yarn run dev
를 실행합니다.그러면 아래와 같은 로그가 표시됩니다.
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Using webpack 4. Reason: future.webpack5 option not enabled https://nextjs.org/docs/messages/webpack5
We detected TypeScript in your project and created a tsconfig.json file for you.
We detected TypeScript in your project and created a tsconfig.json file for you.
Typescript가 있는 것을 찾았으니까, tsconfig.json 만들었어, 라고 하는 것이군요.
진짜 친절.
이제 기본
index.js
을 index.tsx
로 변경해도 제대로 작동합니다.Reference
이 문제에 관하여(Next.js에서 Typescript를 도입 할 때 특히 아무것도하지 않아도된다는 이야기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/toshiokun/items/7b019a3aea6a54ff401e텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)