Skip to content

enchance leavesOnly: true for nullable fields (need append option for Paths util type) #1304

@salisbury-espinosa

Description

@salisbury-espinosa

currrent behavior:

type TestType = {
  test?: null | { someField: number };
};

// PathsFromTestType = 'test' | 'test.someField'
type PathsFromTestType = Paths<
  TestType,
  { leavesOnly: true; maxRecursionDepth: 10 }
>;

expected behavior:
// PathsFromTestType = 'test.someField'

workaroround

type TestType = {
  test?: null | { someField: number };
};

// PathsFromTestType = 'test. someField'
type PathsFromTestType = Paths<
  SetNonNullableDeep<
    TestType,
    Paths<TestType, { leavesOnly: true; maxRecursionDepth: 10 }>
  >,
  { leavesOnly: true; maxRecursionDepth: 10 }
>;

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