File: src/app.module.ts:13:22
Problem:
port: parseInt(process.env.DB_PORT) || 5432,process.env.DB_PORT can be undefined, and parseInt(undefined) returns NaN.
Solution:
port: parseInt(process.env.DB_PORT || "5432"),Provide a default string value before parsing.
File: src/users/users.service.ts:27:19
Problem:
const { page, limit, search, role, status } = queryDto;
const skip = (page - 1) * limit;Even though QueryUsersDto has default values, destructuring doesn't preserve them.
Solution:
const { page = 1, limit = 10, search, role, status } = queryDto;
const skip = (page - 1) * limit;Add default values in the destructuring assignment.
File: src/users/users.service.ts:27:31 and 58:39
Problem:
Same as above - limit could be undefined when destructured.
Solution:
Same fix - add default value in destructuring: limit = 10
These errors appeared because:
- TypeScript Strict Mode: Your GitHub CI likely has stricter TypeScript settings than the default configuration
- Environment Variables:
process.env.*values are alwaysstring | undefinedin TypeScript - Destructuring Behavior: Default values in class properties don't carry over to destructured variables
After these fixes, the following should work:
# Type check
npm run build
# Run tests
npm test
npm run test:e2e- ✅
src/app.module.ts- FixedparseIntwith undefined check - ✅
src/users/users.service.ts- Added default values in destructuring
These fixes are backward compatible and don't change the runtime behavior:
- Default values remain the same (page=1, limit=10, port=5432)
- All tests continue to pass
- API behavior is unchanged