Skip to content

[Wave 200pts] FIX: main.ts declares the same const port variable twice in the same function scope, a compile error #1154

Description

@portableDD

Summary

src/main.ts's bootstrap() function declares const port = configService.get<number>('app.port'); twice — once near the top (used immediately for the isNaN(port) validation check) and again, identically, right before await app.listen(port) near the end of the same function. This is a duplicate block-scoped variable declaration in the same scope, which TypeScript rejects outright (Cannot redeclare block-scoped variable 'port').

Why This Matters

main.ts is the application's actual entry point — a compile error here means nest build/npm run start cannot produce a runnable application at all, independent of every other syntax error found elsewhere in the codebase. This is a small, easy fix, but it is a genuine, currently-committed blocker to booting the app even after every other file-level syntax error is resolved.

What Needs to Be Done

  • Remove the second const port = ... declaration near the end of bootstrap() and reuse the port variable already declared and validated earlier in the function for the app.listen(port) call.
  • Re-run npx tsc --noEmit against main.ts to confirm no redeclaration error remains.
  • Add the file to whatever CI build/typecheck step is introduced to catch this class of error going forward.

Key Files

  • src/main.ts (both const port = configService.get<number>('app.port'); declarations)

Acceptance Criteria

  • port is declared exactly once in bootstrap()
  • npx tsc --noEmit reports no redeclaration error for main.ts
  • The application still validates the port (throws on NaN/falsy) and listens on the correct port after the fix

Points: 200
Category: FIX

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions