.env.development와 env.d.ts는 완전히 다른 목적을 가진 파일입니다:
API_URL=http://localhost:8082
WS_URL=ws://localhost:8082
declare namespace NodeJS {
interface ProcessEnv {
API_URL: string;
WS_URL: string;
NODE_ENV: 'development' | 'production';
}
}
// TypeScript가 타입 체크를 할 수 있습니다
const apiUrl: string = process.env.API_URL; // OK
const port: number = process.env.API_URL; // Error: Type 'string' is not assignable to type 'number'