Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Why does the types returned by 'valueOf()' are incompatible with the type Partial<Temporal.PlainDate>?
[closed]
Closed as unclear by Karl Knechtel on Jun 7, 2025 at 21:23
This question cannot be answered in its current form, because critical information is missing.
This question was closed; new answers can no longer be added. Users with the Vote on Holds ability may vote to reopen this question if it has been improved or closed incorrectly.
This code:
type A = Partial<Temporal.PlainDate>;
const a: A = { day: 1, month: 1, year: 2025 }
yields this error:
Type '{ day: number; month: number; year: number; }' is not assignable to type 'Partial<PlainDate>'.
The types returned by 'valueOf()' are incompatible between these types.
The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
I expect the type check to pass. In my understanding, Partial<X> is a type with all properties of X set to optional, so a should have no error. If this is the intended restriction, then how can I create a Partial<Temporal.PlainDate> instance?
const a = new Temporal.PlainDate(2025, 1, 1) works. I just wonder why using Partial doesn't work here. Reading Temporal.PlainDate.prototype.valueOf() doesn't help.

2 comment threads