Skip to content

Add a typed Vite env declaration file for VITE_* variables in vite-env.d.ts #305

Description

@Jagadeeshftw

📌 Description

src/shared/config/api.ts reads import.meta.env.VITE_API_BASE_URL and VITE_FRONTEND_BASE_URL, but src/vite-env.d.ts does not declare an ImportMetaEnv interface, so these are loosely typed and typos go unnoticed. Add an ImportMetaEnv/ImportMeta augmentation declaring the known VITE_* keys so TypeScript flags misspelled or missing env references at compile time.

💡 Why it matters: Untyped env access lets a typo like VITE_API_BSE_URL compile and fail only at runtime.

🧩 Requirements and context

  • Declare interface ImportMetaEnv with VITE_API_BASE_URL: string and optional VITE_FRONTEND_BASE_URL?: string.
  • Augment ImportMeta with readonly env: ImportMetaEnv.
  • Place the declaration in src/vite-env.d.ts.
  • Confirm api.ts typechecks against the new types.
  • Keep the existing vite/client triple-slash reference.

Non-functional requirements

  • Must be secure, tested, and documented.
  • Should be efficient and easy to review.

🛠️ Suggested execution

1. Fork the repo and create a branch

git checkout -b chore/typed-vite-env

2. Implement changes

  • Write/modify the relevant source: src/vite-env.d.ts
  • Write comprehensive tests: typecheck serves as the gate
  • Add documentation: inline comment listing each VITE_ var
  • Include TSDoc doc comments where applicable
  • Validate security assumptions: only public VITE_ vars declared

3. Test and commit

  • Run tests:
npm run typecheck && npm test
  • Cover edge cases: referencing an undeclared VITE_ key errors
  • Include test output and security notes in the PR description.

Example commit message

chore(types): declare typed ImportMetaEnv for VITE_ vars

✅ Acceptance criteria

  • ImportMetaEnv declares known VITE_ keys
  • ImportMeta.env typed
  • api.ts typechecks
  • Undeclared key reference errors at compile time

🔒 Security notes

Only declare non-secret VITE_ variables; never add server-only secrets to the public env type.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Labels

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions