excessPropertyCheckingInDestructuring.ts(14,30): error TS2322: Type '"invalid"' is not assignable to type '"a" | "b"'.
excessPropertyCheckingInDestructuring.ts(15,30): error TS2322: Type '"invalid"' is not assignable to type '"a" | "b"'.
excessPropertyCheckingInDestructuring.ts(19,38): error TS2353: Object literal may only specify known properties, and 'day' does not exist in type '{ dataType: "a" | "b"; }'.


==== excessPropertyCheckingInDestructuring.ts (3 errors) ====
    declare function foo<T extends { dataType: 'a' | 'b' }>(template: T): [T, any, any];
    declare function bar(template: { dataType: 'a' | 'b' }): [any, any, any];
    
    // These should work without excess property errors - destructuring contexts
    const [, ,] = foo({ dataType: 'a', day: 0 });
    const [, , t] = foo({ dataType: 'a', day: 0 });
    const [x, y, z] = foo({ dataType: 'a', day: 0 });
    
    const [, ,] = bar({ dataType: 'a', day: 0 });
    const [, , u] = bar({ dataType: 'a', day: 0 });
    const [a, b, c] = bar({ dataType: 'a', day: 0 });
    
    // These should still report legitimate type errors
    const [, , invalid1] = foo({ dataType: 'invalid' });
                                 ~~~~~~~~
!!! error TS2322: Type '"invalid"' is not assignable to type '"a" | "b"'.
!!! related TS6500 excessPropertyCheckingInDestructuring.ts:1:34: The expected type comes from property 'dataType' which is declared here on type '{ dataType: "a" | "b"; }'
    const [, , invalid2] = bar({ dataType: 'invalid' });
                                 ~~~~~~~~
!!! error TS2322: Type '"invalid"' is not assignable to type '"a" | "b"'.
!!! related TS6500 excessPropertyCheckingInDestructuring.ts:2:34: The expected type comes from property 'dataType' which is declared here on type '{ dataType: "a" | "b"; }'
    
    // Non-destructuring cases - generic function should work, non-generic should error
    const result1 = foo({ dataType: 'a', day: 0 }); // OK - generic function
    const result2 = bar({ dataType: 'a', day: 0 }); // Error - non-generic with excess property
                                         ~~~
!!! error TS2353: Object literal may only specify known properties, and 'day' does not exist in type '{ dataType: "a" | "b"; }'.
    
    // Assignment destructuring should also work
    let d, e, f: any;
    [d, e, f] = foo({ dataType: 'a', day: 0 });