baconjs / bacon.js

Functional reactive programming library for TypeScript and JavaScript
https://baconjs.github.io
MIT License
6.47k stars 330 forks source link

ObjectTemplate type issue with Date objects #806

Open pvakevai opened 1 year ago

pvakevai commented 1 year ago

ObjectTemplate type mappings are wrong, combining a template with a field of type Date will not be typed correctly. See

Screenshot 2023-01-12 at 11 22 40
kaisellgren commented 1 year ago

@raimohanska The issue lies within:

export declare type ObjectTemplate<O> = {
    [K in keyof O]: O[K] extends Observable<infer I> ? I : (O[K] extends Record<any, any> ? ObjectTemplate<O[K]> : (O[K] extends Array<infer I2> ? ArrayTemplate<I2> : O[K]));
};

This should include a separate check for Date. Right now the check O[K] extends Record<any, any> matches Date objects.

raimohanska commented 1 year ago

Drop a pull request if you want this fixed. I honestly haven’t touched the library for a long time but I believe a fix release can be made for this.