Split tests

This commit is contained in:
Andrew Branch
2022-05-12 10:06:10 -07:00
parent b00e6b51a2
commit 73e58ea929
4 changed files with 38 additions and 33 deletions

View File

@@ -21248,11 +21248,15 @@ namespace ts {
type;
}
function getWidenedLiteralLikeTypeForContextualType(type: Type, contextualType: Type | undefined, contextNode?: Node) {
if (!isLiteralOfContextualType(type, contextualType) && !(contextNode && isLiteralOfContextualType(type, instantiateContextualType(contextualType, contextNode)))) {
type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
function getWidenedLiteralLikeTypeForContextualType(type: Type, contextualType: Type | undefined, node?: Node) {
if (isLiteralOfContextualType(type, contextualType)) {
return type;
}
return type;
const instantiatedContextualType = node && instantiateContextualType(contextualType, node) || contextualType;
if (instantiatedContextualType !== contextualType && isLiteralOfContextualType(type, instantiatedContextualType)) {
return type;
}
return getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
}
function getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(type: Type | undefined, contextualSignatureReturnType: Type | undefined, isAsync: boolean) {

View File

@@ -0,0 +1,25 @@
declare function f<T>(): T;
const {} = f(); // error
const { p1 } = f(); // error
const [] = f(); // error
const [e1, e2] = f(); // error
// 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)),
})
);

View File

@@ -0,0 +1,3 @@
declare function pick<O, T extends keyof O>(keys: T[], obj?: O): Pick<O, T>;
const _ = pick(['b'], { a: 'a', b: 'b' }); // T: "b"
const { } = pick(['b'], { a: 'a', b: 'b' }); // T: "b" | "a" ??? (before fix)

View File

@@ -1,29 +1,2 @@
declare function f2<T>(cb: () => T): T;
const [e1, e2, e3] = f2(() => [1, "hi", true]);
declare function f1<T>(): T;
const {} = f1(); // error
const { p1 } = f1(); // error
declare function pick<O, T extends keyof O>(keys: T[], obj?: O): Pick<O, T>;
const _ = pick(['b'], { a: 'a', b: 'b' }); // T: "b"
const { } = pick(['b'], { a: 'a', b: 'b' }); // T: "b" | "a" ???
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)),
funcB: (...p) => d(f.funcB(...p)),
funcC: (...p) => d(f.funcC(...p))
})
);
declare function f<T>(cb: () => T): T;
const [e1, e2, e3] = f(() => [1, "hi", true]);