tsconfig.json => include에 next-env.d.ts가 포함되어 있어야 함.
next-env.d.ts 파일에 작성하면 재선언 할 필요없이 전역으로 사용 가능
대신 프로젝트 재구동 시 next-env.d.ts파일이 새로 생성돼서 덮어써지니 주의
대안 : project root에 global.d.ts 파일을 새로 만들어서 아래와 같이 전역 타입선언하면 해결
next-env.d.ts
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// 전역 타입 선언
interface Props {
id: number;
title: string;
}
type Props = {
id: number;
title: string;
}
// 전역 상수 선언
declare const API_BASE_URL: string;