ts-toolbelt icon indicating copy to clipboard operation
ts-toolbelt copied to clipboard

`Object.Paths` not produced error with optional sub props.

Open ozum opened this issue 3 years ago • 3 comments

Hi,

I would like to report a bug.

🐞 Bug Report

Describe the bug

Object.Paths does not produce an error if optional properties exist in sub properties.

Reproduce the bug

import { Object } from 'ts-toolbelt'

export interface LineItem {
  modifications: Record<string, {rate?: number; amount?: number}>
}

export interface Mandatory {
  modifications: Record<string, {rate: number; amount: number}>
}

export function useVModel<PROPS extends object, PATH extends Object.Paths<PROPS>>(
  props: PROPS,
  path: PATH,
): any {}

export function useLineItem(
  lineItem: LineItem,
  mandatory: Mandatory,
): any {
  useVModel(lineItem, ['XXXXXXX']) // First Call
  useVModel(mandatory, ['XXXXXXX']) // Second Call
}

Expected behavior

Both calls should produce errors.

What happens

The first call does not produce an error, whereas the second call produces an error.

Screenshots

image

Additional context

"ts-toolbelt": 9.6.0 "typescript": 4.2.3 "node": 15.8.0

ozum avatar Mar 24 '21 09:03 ozum

Thanks for reporting this

millsp avatar Mar 29 '21 21:03 millsp

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 02 '21 17:06 stale[bot]

Any updates on this issue?

yannickpschroeder avatar Jun 29 '22 09:06 yannickpschroeder