File: bindingPatternCannotBeOnlyInferenceSource.errors.txt

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (44 lines) | stat: -rw-r--r-- 2,291 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts(2,7): error TS2571: Object is of type 'unknown'.
tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts(3,9): error TS2339: Property 'p1' does not exist on type 'unknown'.
tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts(4,7): error TS2461: Type 'unknown' is not an array type.
tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts(4,7): error TS2571: Object is of type 'unknown'.
tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts(5,7): error TS2461: Type 'unknown' is not an array type.


==== tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts (5 errors) ====
    declare function f<T>(): T;
    const {} = f();       // error (only in strictNullChecks)
          ~~
!!! error TS2571: Object is of type 'unknown'.
    const { p1 } = f();   // error
            ~~
!!! error TS2339: Property 'p1' does not exist on type 'unknown'.
    const [] = f();       // error
          ~~
!!! error TS2461: Type 'unknown' is not an array type.
          ~~
!!! error TS2571: Object is of type 'unknown'.
    const [e1, e2] = f(); // error
          ~~~~~~~~
!!! error TS2461: Type 'unknown' is not an array type.
    
    // Repro from #43605
    type Dispatch<A = { type: any; [extraProps: string]: any }> = { <T extends A>(action: T): T };
    type IFuncs = { readonly [key: string]: (...p: any) => void };
    type IDestructuring<T extends IFuncs> = { readonly [key in keyof T]?: (...p: Parameters<T[key]>) => void };
    type Destructuring<T extends IFuncs, U extends IDestructuring<T>> = (dispatch: Dispatch<any>, funcs: T) => U;
    const funcs1 = {
        funcA: (a: boolean): void => {},
        funcB: (b: string, bb: string): void => {},
        funcC: (c: number, cc: number, ccc: boolean): void => {},
    };
    type TFuncs1 = typeof funcs1;
    declare function useReduxDispatch1<T extends IDestructuring<TFuncs1>>(destructuring: Destructuring<TFuncs1, T>): T;
    const {} = useReduxDispatch1(
        (d, f) => ({
            funcA: (...p) => d(f.funcA(...p)), // p should be inferrable
            funcB: (...p) => d(f.funcB(...p)),
            funcC: (...p) => d(f.funcC(...p)),
        })
    );