mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
44 lines
2.3 KiB
Plaintext
44 lines
2.3 KiB
Plaintext
bindingPatternCannotBeOnlyInferenceSource.ts(2,7): error TS2571: Object is of type 'unknown'.
|
|
bindingPatternCannotBeOnlyInferenceSource.ts(3,9): error TS2339: Property 'p1' does not exist on type 'unknown'.
|
|
bindingPatternCannotBeOnlyInferenceSource.ts(4,7): error TS2488: Type 'unknown' must have a '[Symbol.iterator]()' method that returns an iterator.
|
|
bindingPatternCannotBeOnlyInferenceSource.ts(4,7): error TS2571: Object is of type 'unknown'.
|
|
bindingPatternCannotBeOnlyInferenceSource.ts(5,7): error TS2488: Type 'unknown' must have a '[Symbol.iterator]()' method that returns an iterator.
|
|
|
|
|
|
==== 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 TS2488: Type 'unknown' must have a '[Symbol.iterator]()' method that returns an iterator.
|
|
~~
|
|
!!! error TS2571: Object is of type 'unknown'.
|
|
const [e1, e2] = f(); // error
|
|
~~~~~~~~
|
|
!!! error TS2488: Type 'unknown' must have a '[Symbol.iterator]()' method that returns an iterator.
|
|
|
|
// 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)),
|
|
})
|
|
);
|
|
|