Skip to content

refactor(tests): Replace 'as any' type assertions in edge case tests #64

@AngusHsu

Description

@AngusHsu

Description

ESLint is generating warnings for the use of `as any` type assertions in edge case tests.

Location

`src/tests/low-coverage-countries.test.ts` lines 367-368 (and potentially other similar cases)

Current Code

```typescript
expect(validateNationalId('HUN', null as any).isValid).toBe(false);
expect(validateNationalId('ISL', undefined as any).isValid).toBe(false);
```

Warning Message

Unexpected any. Specify a different type
@typescript-eslint/no-explicit-any

Proposed Solution

Replace `as any` with `as unknown as string` to maintain type safety while still testing edge cases:

```typescript
expect(validateNationalId('HUN', null as unknown as string).isValid).toBe(false);
expect(validateNationalId('ISL', undefined as unknown as string).isValid).toBe(false);
```

Tasks

  • Audit all test files for `as any` usage
  • Replace with `as unknown as string` or appropriate type
  • Verify all tests still pass
  • Ensure ESLint warnings are resolved

Impact

  • Low priority - these are warnings, not errors
  • All checks currently pass
  • Improves code quality and type safety

Labels

refactor, tests, code-quality, tech-debt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions