Skip to content

[TEST] Add dedicated tests for ExpandGlob type #49

@kakasoo

Description

@kakasoo

Feature Request

  • Extensions of existing features
  • Propose a type that didn't exist before

Type Expectation

There is no dedicated test file for src/types/ExpandGlob.ts. Currently it is only verified indirectly through DeepStrictPick's glob tests, so dedicated tests are needed to directly verify ExpandGlob's edge cases.

Example Type

import { ExpandGlob, Equal } from '../../src';

// Basic: top-level glob
type Q1 = ExpandGlob<{ a: 1; b: 2; c: 3 }, "*">;
type A1 = Equal<Q1, "a" | "b" | "c">;

// Nested glob
type Q2 = ExpandGlob<{ a: { b: 1; c: 2 } }, "a.*">;
type A2 = Equal<Q2, "a.b" | "a.c">;

// Array inner glob
type Q3 = ExpandGlob<{ items: { id: number; name: string }[] }, "items[*].*">;
type A3 = Equal<Q3, "items[*].id" | "items[*].name">;

// Non-glob passthrough
type Q4 = ExpandGlob<{ a: { b: 1 } }, "a.b">;
type A4 = Equal<Q4, "a.b">;

Proposed Solution

Create a new test/features/ExpandGlob.ts file to test the following scenarios.

Test Requirements

All changes must include the following tests:

  1. Backward Compatibility

    • All existing tests must pass
    • Add tests to verify that existing type behavior remains unchanged
  2. Feature Verification

    • * (top-level glob)
    • a.* (nested glob)
    • a[*].* (array inner glob)
    • Non-glob regular key passthrough
    • Mixed glob + regular key (when passed as union)
  3. Complex Type Stability

    • 3+ levels of nested glob (a.b.*)
    • Array within array glob (items[*].sub[*].*)
    • Glob applied to empty object
    • Glob on objects with branded type properties
    • Glob applied to tuple elements ([{ a: 1 }, { b: 2 }])
    • Glob applied to readonly arrays

How to verify:

npm run build:test && npm run test
npm run prettier

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions