-
-
Notifications
You must be signed in to change notification settings - Fork 103
Description
Summary
Add test coverage to validate type narrowing behavior for the Entry type after removing explicit type assertion in package/environments/base.ts.
Identified during PR #788 review as a minor concern.
Background
In PR #788, an unnecessary type assertion was removed from package/environments/base.ts:
// Before:
const pathArray = Array.isArray(previousPaths)
? (previousPaths as string[]) // explicit assertion
: [previousPaths as string]
// After:
const pathArray = Array.isArray(previousPaths)
? previousPaths // TypeScript narrows the type automatically
: [previousPaths as string]This change relies on TypeScript's type narrowing to infer that previousPaths is string[] when Array.isArray() returns true.
Concern
If the Entry type definition from webpack changes, this type narrowing might break and cause type errors. While this is unlikely and would be caught by TypeScript, it's worth having explicit test coverage.
Tasks
- Review existing test coverage for entry object handling in
test/typescript/securityValidation.test.js - Add test case that validates entry object type handling with various Entry shapes
- Document the Entry type expectations in comments if not already done
Related Issues
- TypeScript ESLint Technical Debt: 381 Suppressed Errors Requiring Resolution #783 - TypeScript ESLint technical debt
- PR Fix TypeScript ESLint errors (Phase 1): Auto-fixes and simple manual fixes #788 - Where this change was made
Notes
This is low priority - the type narrowing is correct and TypeScript will catch any issues. This is more about defensive programming and documentation.