From ffb8f5d43538e01cdf6be26e7809f379b189f1db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 4 Aug 2025 09:57:28 +0200 Subject: [PATCH] Add tests for contextual param type assignment in nested return type inference scenarios --- ...amTypeVsNestedReturnTypeInference1.symbols | 89 ++++++ ...aramTypeVsNestedReturnTypeInference1.types | 98 +++++++ ...amTypeVsNestedReturnTypeInference2.symbols | 273 ++++++++++++++++++ ...aramTypeVsNestedReturnTypeInference2.types | 205 +++++++++++++ ...amTypeVsNestedReturnTypeInference3.symbols | 245 ++++++++++++++++ ...aramTypeVsNestedReturnTypeInference3.types | 189 ++++++++++++ ...amTypeVsNestedReturnTypeInference4.symbols | 207 +++++++++++++ ...aramTypeVsNestedReturnTypeInference4.types | 174 +++++++++++ ...alParamTypeVsNestedReturnTypeInference1.ts | 34 +++ ...alParamTypeVsNestedReturnTypeInference2.ts | 92 ++++++ ...alParamTypeVsNestedReturnTypeInference3.ts | 76 +++++ ...alParamTypeVsNestedReturnTypeInference4.ts | 62 ++++ 12 files changed, 1744 insertions(+) create mode 100644 tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference1.symbols create mode 100644 tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference1.types create mode 100644 tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference2.symbols create mode 100644 tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference2.types create mode 100644 tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference3.symbols create mode 100644 tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference3.types create mode 100644 tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference4.symbols create mode 100644 tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference4.types create mode 100644 tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference1.ts create mode 100644 tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference2.ts create mode 100644 tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference3.ts create mode 100644 tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference4.ts diff --git a/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference1.symbols b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference1.symbols new file mode 100644 index 0000000000000..5e148ae9c3a3a --- /dev/null +++ b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference1.symbols @@ -0,0 +1,89 @@ +//// [tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference1.ts] //// + +=== contextualParamTypeVsNestedReturnTypeInference1.ts === +interface Effect { +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 0, 0)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 0, 17)) + + _A: A; +>_A : Symbol(Effect._A, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 0, 21)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 0, 17)) +} + +declare function effectGen(f: () => AEff): Effect; +>effectGen : Symbol(effectGen, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 2, 1)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 4, 27)) +>f : Symbol(f, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 4, 33)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 4, 27)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 0, 0)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 4, 27)) + +declare function effectFn>( +>effectFn : Symbol(effectFn, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 4, 62)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 6, 26)) +>Args : Symbol(Args, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 6, 31)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) + + body: (...args: Args) => unknown, +>body : Symbol(body, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 6, 57)) +>args : Symbol(args, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 7, 9)) +>Args : Symbol(Args, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 6, 31)) + +): (...args: Args) => Effect; +>args : Symbol(args, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 8, 4)) +>Args : Symbol(Args, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 6, 31)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 0, 0)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 6, 26)) + +declare function layerEffect(tag: Tag, effect: Effect): unknown; +>layerEffect : Symbol(layerEffect, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 8, 35)) +>S : Symbol(S, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 10, 29)) +>tag : Symbol(tag, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 10, 32)) +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 10, 73)) +>S : Symbol(S, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 10, 29)) +>effect : Symbol(effect, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 10, 44)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 0, 0)) +>S : Symbol(S, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 10, 29)) + +interface Tag { +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 10, 73)) +>Type : Symbol(Type, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 12, 14)) + + _Type: Type; +>_Type : Symbol(Tag._Type, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 12, 21)) +>Type : Symbol(Type, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 12, 14)) +} + +declare const Foo: Tag<{ +>Foo : Symbol(Foo, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 16, 13)) +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 10, 73)) + + fn: (a: string) => unknown; +>fn : Symbol(fn, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 16, 24)) +>a : Symbol(a, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 17, 7)) + +}>; + +layerEffect( +>layerEffect : Symbol(layerEffect, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 8, 35)) + + Foo, +>Foo : Symbol(Foo, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 16, 13)) + + effectGen(function () { +>effectGen : Symbol(effectGen, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 2, 1)) + + return { + fn: effectFn(function (a) { +>fn : Symbol(fn, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 23, 12)) +>effectFn : Symbol(effectFn, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 4, 62)) +>a : Symbol(a, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 24, 29)) + + a; // string +>a : Symbol(a, Decl(contextualParamTypeVsNestedReturnTypeInference1.ts, 24, 29)) + + }), + }; + }), +); + diff --git a/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference1.types b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference1.types new file mode 100644 index 0000000000000..578644d0ccd76 --- /dev/null +++ b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference1.types @@ -0,0 +1,98 @@ +//// [tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference1.ts] //// + +=== contextualParamTypeVsNestedReturnTypeInference1.ts === +interface Effect { + _A: A; +>_A : A +> : ^ +} + +declare function effectGen(f: () => AEff): Effect; +>effectGen : (f: () => AEff) => Effect +> : ^ ^^ ^^ ^^^^^ +>f : () => AEff +> : ^^^^^^ + +declare function effectFn>( +>effectFn : >(body: (...args: Args) => unknown) => (...args: Args) => Effect +> : ^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ + + body: (...args: Args) => unknown, +>body : (...args: Args) => unknown +> : ^^^^ ^^ ^^^^^ +>args : Args +> : ^^^^ + +): (...args: Args) => Effect; +>args : Args +> : ^^^^ + +declare function layerEffect(tag: Tag, effect: Effect): unknown; +>layerEffect : (tag: Tag, effect: Effect) => unknown +> : ^ ^^ ^^ ^^ ^^ ^^^^^ +>tag : Tag +> : ^^^^^^ +>effect : Effect +> : ^^^^^^^^^ + +interface Tag { + _Type: Type; +>_Type : Type +> : ^^^^ +} + +declare const Foo: Tag<{ +>Foo : Tag<{ fn: (a: string) => unknown; }> +> : ^^^^^^^^^^ ^^^^ + + fn: (a: string) => unknown; +>fn : (a: string) => unknown +> : ^ ^^ ^^^^^ +>a : string +> : ^^^^^^ + +}>; + +layerEffect( +>layerEffect( Foo, effectGen(function () { return { fn: effectFn(function (a) { a; // string }), }; }),) : unknown +> : ^^^^^^^ +>layerEffect : (tag: Tag, effect: Effect) => unknown +> : ^ ^^ ^^ ^^ ^^ ^^^^^ + + Foo, +>Foo : Tag<{ fn: (a: string) => unknown; }> +> : ^^^^^^^^^^ ^^^^ + + effectGen(function () { +>effectGen(function () { return { fn: effectFn(function (a) { a; // string }), }; }) : Effect<{ fn: (a: string) => Effect; }> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>effectGen : (f: () => AEff) => Effect +> : ^ ^^ ^^ ^^^^^ +>function () { return { fn: effectFn(function (a) { a; // string }), }; } : () => { fn: (a: string) => Effect; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + return { +>{ fn: effectFn(function (a) { a; // string }), } : { fn: (a: string) => Effect; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + fn: effectFn(function (a) { +>fn : (a: string) => Effect +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>effectFn(function (a) { a; // string }) : (a: string) => Effect +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>effectFn : >(body: (...args: Args) => unknown) => (...args: Args) => Effect +> : ^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>function (a) { a; // string } : (a: string) => void +> : ^ ^^^^^^^^^^^^^^^^^ +>a : string +> : ^^^^^^ + + a; // string +>a : string +> : ^^^^^^ + + }), + }; + }), +); + diff --git a/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference2.symbols b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference2.symbols new file mode 100644 index 0000000000000..ecd0513a72a74 --- /dev/null +++ b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference2.symbols @@ -0,0 +1,273 @@ +//// [tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference2.ts] //// + +=== contextualParamTypeVsNestedReturnTypeInference2.ts === +type Covariant = (_: never) => A; +>Covariant : Symbol(Covariant, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 0)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 15)) +>_ : Symbol(_, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 21)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 15)) + +interface Effect { +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 36)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 2, 17)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 2, 23)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 2, 38)) + + readonly _A: Covariant; +>_A : Symbol(Effect._A, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 2, 55)) +>Covariant : Symbol(Covariant, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 0)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 2, 17)) + + readonly _E: Covariant; +>_E : Symbol(Effect._E, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 3, 28)) +>Covariant : Symbol(Covariant, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 0)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 2, 23)) + + readonly _R: Covariant; +>_R : Symbol(Effect._R, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 4, 28)) +>Covariant : Symbol(Covariant, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 0)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 2, 38)) +} + +declare function effectGen, AEff>( +>effectGen : Symbol(effectGen, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 6, 1)) +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 8, 27)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 36)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 8, 61)) + + f: () => Generator +>f : Symbol(f, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 8, 68)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 8, 27)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 8, 61)) + +): Effect< +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 36)) + + AEff, +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 8, 61)) + + [Eff] extends [never] +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 8, 27)) + + ? never + : [Eff] extends [Effect] +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 8, 27)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 36)) +>_A : Symbol(_A, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 14, 33)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 14, 43)) +>_R : Symbol(_R, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 14, 52)) + + ? E +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 14, 43)) + + : never, + [Eff] extends [never] +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 8, 27)) + + ? never + : [Eff] extends [Effect] +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 8, 27)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 36)) +>_A : Symbol(_A, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 19, 33)) +>_E : Symbol(_E, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 19, 43)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 19, 53)) + + ? R +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 19, 53)) + + : never +>; + +declare function effectFn< +>effectFn : Symbol(effectFn, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 22, 2)) + + Eff extends Effect, +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 24, 26)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 36)) + + AEff, +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 25, 36)) + + Args extends Array +>Args : Symbol(Args, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 26, 7)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) + +>( + body: (...args: Args) => Generator +>body : Symbol(body, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 28, 2)) +>args : Symbol(args, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 29, 9)) +>Args : Symbol(Args, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 26, 7)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 24, 26)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 25, 36)) + +): ( + ...args: Args +>args : Symbol(args, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 30, 4)) +>Args : Symbol(Args, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 26, 7)) + +) => Effect< +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 36)) + + AEff, +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 25, 36)) + + [Eff] extends [never] +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 24, 26)) + + ? never + : [Eff] extends [Effect] +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 24, 26)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 36)) +>_A : Symbol(_A, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 36, 33)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 36, 43)) +>_R : Symbol(_R, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 36, 52)) + + ? E +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 36, 43)) + + : never, + [Eff] extends [never] +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 24, 26)) + + ? never + : [Eff] extends [Effect] +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 24, 26)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 36)) +>_A : Symbol(_A, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 41, 33)) +>_E : Symbol(_E, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 41, 43)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 41, 53)) + + ? R +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 41, 53)) + + : never +>; + +interface Tag { +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 65, 11), Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 44, 2)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 46, 14)) +>Value : Symbol(Value, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 46, 24)) + + readonly _op: "Tag"; +>_op : Symbol(Tag._op, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 46, 40)) + + readonly Service: Value; +>Service : Symbol(Tag.Service, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 47, 22)) +>Value : Symbol(Value, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 46, 24)) + + readonly Identifier: Id; +>Identifier : Symbol(Tag.Identifier, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 48, 26)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 46, 14)) +} + +interface TagClassShape { +>TagClassShape : Symbol(TagClassShape, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 50, 1)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 52, 24), Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 53, 23)) +>Shape : Symbol(Shape, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 52, 27)) + + readonly Type: Shape; +>Type : Symbol(TagClassShape.Type, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 52, 36)) +>Shape : Symbol(Shape, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 52, 27)) + + readonly Id: Id; +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 52, 24), Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 53, 23)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 52, 24), Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 53, 23)) +} + +interface TagClass extends Tag { +>TagClass : Symbol(TagClass, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 55, 1)) +>Self : Symbol(Self, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 57, 19)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 57, 24)) +>Type : Symbol(Type, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 57, 43)) +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 65, 11), Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 44, 2)) +>Self : Symbol(Self, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 57, 19)) +>Type : Symbol(Type, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 57, 43)) + + new (_: never): TagClassShape; +>_ : Symbol(_, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 58, 7)) +>TagClassShape : Symbol(TagClassShape, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 50, 1)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 57, 24)) +>Type : Symbol(Type, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 57, 43)) + + readonly key: Id; +>key : Symbol(TagClass.key, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 58, 42)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 57, 24)) +} + +declare function layerEffect( +>layerEffect : Symbol(layerEffect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 60, 1)) +>I : Symbol(I, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 62, 29)) +>S : Symbol(S, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 62, 31)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 62, 34)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 62, 37)) + + tag: Tag, +>tag : Symbol(tag, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 62, 41)) +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 65, 11), Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 44, 2)) +>I : Symbol(I, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 62, 29)) +>S : Symbol(S, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 62, 31)) + + effect: Effect +>effect : Symbol(effect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 63, 17)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 36)) +>S : Symbol(S, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 62, 31)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 62, 34)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 62, 37)) + +): unknown; + +declare function Tag( +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 65, 11), Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 44, 2)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 67, 21)) + + id: Id +>id : Symbol(id, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 67, 46)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 67, 21)) + +): () => TagClass; +>Self : Symbol(Self, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 69, 4)) +>Shape : Symbol(Shape, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 69, 9)) +>TagClass : Symbol(TagClass, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 55, 1)) +>Self : Symbol(Self, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 69, 4)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 67, 21)) +>Shape : Symbol(Shape, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 69, 9)) + +class Foo extends Tag("Foo")< +>Foo : Symbol(Foo, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 69, 48)) +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 65, 11), Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 44, 2)) + + Foo, +>Foo : Symbol(Foo, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 69, 48)) + { + fn: (a: string) => Effect; +>fn : Symbol(fn, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 73, 3)) +>a : Symbol(a, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 74, 9)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 0, 36)) + } +>() {} + +layerEffect( +>layerEffect : Symbol(layerEffect, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 60, 1)) + + Foo, +>Foo : Symbol(Foo, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 69, 48)) + + effectGen(function* () { +>effectGen : Symbol(effectGen, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 6, 1)) + + return { + fn: effectFn(function* (a) { +>fn : Symbol(fn, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 81, 12)) +>effectFn : Symbol(effectFn, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 22, 2)) +>a : Symbol(a, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 82, 30)) + + a; // string +>a : Symbol(a, Decl(contextualParamTypeVsNestedReturnTypeInference2.ts, 82, 30)) + + }), + }; + }) +); + diff --git a/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference2.types b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference2.types new file mode 100644 index 0000000000000..ec3cb802a39c3 --- /dev/null +++ b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference2.types @@ -0,0 +1,205 @@ +//// [tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference2.ts] //// + +=== Performance Stats === +Type Count: 1,000 +Instantiation count: 2,500 + +=== contextualParamTypeVsNestedReturnTypeInference2.ts === +type Covariant = (_: never) => A; +>Covariant : Covariant +> : ^^^^^^^^^^^^ +>_ : never +> : ^^^^^ + +interface Effect { + readonly _A: Covariant; +>_A : Covariant +> : ^^^^^^^^^^^^ + + readonly _E: Covariant; +>_E : Covariant +> : ^^^^^^^^^^^^ + + readonly _R: Covariant; +>_R : Covariant +> : ^^^^^^^^^^^^ +} + +declare function effectGen, AEff>( +>effectGen : , AEff>(f: () => Generator) => Effect] ? E : never, [Eff] extends [never] ? never : [Eff] extends [Effect] ? R : never> +> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^ + + f: () => Generator +>f : () => Generator +> : ^^^^^^ + +): Effect< + AEff, + [Eff] extends [never] + ? never + : [Eff] extends [Effect] + ? E + : never, + [Eff] extends [never] + ? never + : [Eff] extends [Effect] + ? R + : never +>; + +declare function effectFn< +>effectFn : , AEff, Args extends Array>(body: (...args: Args) => Generator) => (...args: Args) => Effect] ? E : never, [Eff] extends [never] ? never : [Eff] extends [Effect] ? R : never> +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ + + Eff extends Effect, + AEff, + Args extends Array +>( + body: (...args: Args) => Generator +>body : (...args: Args) => Generator +> : ^^^^ ^^ ^^^^^ +>args : Args +> : ^^^^ + +): ( + ...args: Args +>args : Args +> : ^^^^ + +) => Effect< + AEff, + [Eff] extends [never] + ? never + : [Eff] extends [Effect] + ? E + : never, + [Eff] extends [never] + ? never + : [Eff] extends [Effect] + ? R + : never +>; + +interface Tag { + readonly _op: "Tag"; +>_op : "Tag" +> : ^^^^^ + + readonly Service: Value; +>Service : Value +> : ^^^^^ + + readonly Identifier: Id; +>Identifier : Id +> : ^^ +} + +interface TagClassShape { + readonly Type: Shape; +>Type : Shape +> : ^^^^^ + + readonly Id: Id; +>Id : Id +> : ^^ +} + +interface TagClass extends Tag { + new (_: never): TagClassShape; +>_ : never +> : ^^^^^ + + readonly key: Id; +>key : Id +> : ^^ +} + +declare function layerEffect( +>layerEffect : (tag: Tag, effect: Effect) => unknown +> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^ + + tag: Tag, +>tag : Tag +> : ^^^^^^^^^ + + effect: Effect +>effect : Effect +> : ^^^^^^^^^^^^^^^ + +): unknown; + +declare function Tag( +>Tag : (id: Id) => () => TagClass +> : ^^^^^^^ ^^^^^^^^^ ^^ ^^ ^^^^^ + + id: Id +>id : Id +> : ^^ + +): () => TagClass; + +class Foo extends Tag("Foo")< +>Foo : Foo +> : ^^^ +>Tag("Foo")< Foo, { fn: (a: string) => Effect; }>() : TagClassShape<"Foo", { fn: (a: string) => Effect; }> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ +>Tag("Foo") : () => TagClass +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Tag : (id: Id) => () => TagClass +> : ^^^^^^^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>"Foo" : "Foo" +> : ^^^^^ + + Foo, + { + fn: (a: string) => Effect; +>fn : (a: string) => Effect +> : ^ ^^ ^^^^^ +>a : string +> : ^^^^^^ + } +>() {} + +layerEffect( +>layerEffect( Foo, effectGen(function* () { return { fn: effectFn(function* (a) { a; // string }), }; })) : unknown +> : ^^^^^^^ +>layerEffect : (tag: Tag, effect: Effect) => unknown +> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^ + + Foo, +>Foo : typeof Foo +> : ^^^^^^^^^^ + + effectGen(function* () { +>effectGen(function* () { return { fn: effectFn(function* (a) { a; // string }), }; }) : Effect<{ fn: (a: string) => Effect; }, never, never> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>effectGen : , AEff>(f: () => Generator) => Effect] ? E : never, [Eff] extends [never] ? never : [Eff] extends [Effect] ? R : never> +> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^ +>function* () { return { fn: effectFn(function* (a) { a; // string }), }; } : () => Generator Effect; }, never> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + return { +>{ fn: effectFn(function* (a) { a; // string }), } : { fn: (a: string) => Effect; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + fn: effectFn(function* (a) { +>fn : (a: string) => Effect +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>effectFn(function* (a) { a; // string }) : (a: string) => Effect +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>effectFn : , AEff, Args extends Array>(body: (...args: Args) => Generator) => (...args: Args) => Effect] ? E : never, [Eff] extends [never] ? never : [Eff] extends [Effect] ? R : never> +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>function* (a) { a; // string } : (a: string) => Generator +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>a : string +> : ^^^^^^ + + a; // string +>a : string +> : ^^^^^^ + + }), + }; + }) +); + diff --git a/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference3.symbols b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference3.symbols new file mode 100644 index 0000000000000..5d658092c0b65 --- /dev/null +++ b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference3.symbols @@ -0,0 +1,245 @@ +//// [tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference3.ts] //// + +=== contextualParamTypeVsNestedReturnTypeInference3.ts === +type Covariant = (_: never) => A; +>Covariant : Symbol(Covariant, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 0)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 15)) +>_ : Symbol(_, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 21)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 15)) + +interface Effect { +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 36)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 2, 17)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 2, 23)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 2, 38)) + + readonly _A: Covariant; +>_A : Symbol(Effect._A, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 2, 55)) +>Covariant : Symbol(Covariant, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 0)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 2, 17)) + + readonly _E: Covariant; +>_E : Symbol(Effect._E, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 3, 28)) +>Covariant : Symbol(Covariant, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 0)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 2, 23)) + + readonly _R: Covariant; +>_R : Symbol(Effect._R, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 4, 28)) +>Covariant : Symbol(Covariant, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 0)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 2, 38)) +} + +declare function effectGen, AEff>( +>effectGen : Symbol(effectGen, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 6, 1)) +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 8, 27)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 36)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 8, 61)) + + f: () => Generator, +>f : Symbol(f, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 8, 68)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 8, 27)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 8, 61)) + +): Effect< +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 36)) + + AEff, +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 8, 61)) + + [Eff] extends [Effect] ? E : never, +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 8, 27)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 36)) +>_A : Symbol(_A, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 12, 29)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 12, 39)) +>_R : Symbol(_R, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 12, 48)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 12, 39)) + + [Eff] extends [Effect] ? R : never +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 8, 27)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 36)) +>_A : Symbol(_A, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 13, 29)) +>_E : Symbol(_E, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 13, 39)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 13, 49)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 13, 49)) + +>; + +declare function effectFn< +>effectFn : Symbol(effectFn, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 14, 2)) + + Eff extends Effect, +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 16, 26)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 36)) + + AEff, +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 17, 36)) + + Args extends Array, +>Args : Symbol(Args, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 18, 7)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) + +>( + body: (...args: Args) => Generator, +>body : Symbol(body, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 20, 2)) +>args : Symbol(args, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 21, 9)) +>Args : Symbol(Args, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 18, 7)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 16, 26)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 17, 36)) + +): ( + ...args: Args +>args : Symbol(args, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 22, 4)) +>Args : Symbol(Args, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 18, 7)) + +) => Effect< +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 36)) + + AEff, +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 17, 36)) + + [Eff] extends [Effect] ? E : never, +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 16, 26)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 36)) +>_A : Symbol(_A, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 26, 29)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 26, 39)) +>_R : Symbol(_R, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 26, 48)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 26, 39)) + + [Eff] extends [Effect] ? R : never +>Eff : Symbol(Eff, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 16, 26)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 36)) +>_A : Symbol(_A, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 27, 29)) +>_E : Symbol(_E, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 27, 39)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 27, 49)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 27, 49)) + +>; + +interface Tag { +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 49, 11), Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 28, 2)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 30, 14)) +>Value : Symbol(Value, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 30, 24)) + + readonly _op: "Tag"; +>_op : Symbol(Tag._op, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 30, 40)) + + readonly Service: Value; +>Service : Symbol(Tag.Service, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 31, 22)) +>Value : Symbol(Value, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 30, 24)) + + readonly Identifier: Id; +>Identifier : Symbol(Tag.Identifier, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 32, 26)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 30, 14)) +} + +interface TagClassShape { +>TagClassShape : Symbol(TagClassShape, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 34, 1)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 36, 24), Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 37, 23)) +>Shape : Symbol(Shape, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 36, 27)) + + readonly Type: Shape; +>Type : Symbol(TagClassShape.Type, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 36, 36)) +>Shape : Symbol(Shape, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 36, 27)) + + readonly Id: Id; +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 36, 24), Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 37, 23)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 36, 24), Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 37, 23)) +} + +interface TagClass extends Tag { +>TagClass : Symbol(TagClass, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 39, 1)) +>Self : Symbol(Self, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 41, 19)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 41, 24)) +>Type : Symbol(Type, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 41, 43)) +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 49, 11), Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 28, 2)) +>Self : Symbol(Self, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 41, 19)) +>Type : Symbol(Type, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 41, 43)) + + new (_: never): TagClassShape; +>_ : Symbol(_, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 42, 7)) +>TagClassShape : Symbol(TagClassShape, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 34, 1)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 41, 24)) +>Type : Symbol(Type, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 41, 43)) + + readonly key: Id; +>key : Symbol(TagClass.key, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 42, 42)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 41, 24)) +} + +declare function layerEffect( +>layerEffect : Symbol(layerEffect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 44, 1)) +>I : Symbol(I, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 46, 29)) +>S : Symbol(S, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 46, 31)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 46, 34)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 46, 37)) + + tag: Tag, +>tag : Symbol(tag, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 46, 41)) +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 49, 11), Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 28, 2)) +>I : Symbol(I, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 46, 29)) +>S : Symbol(S, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 46, 31)) + + effect: Effect, +>effect : Symbol(effect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 47, 17)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 36)) +>S : Symbol(S, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 46, 31)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 46, 34)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 46, 37)) + +): unknown; + +declare function Tag( +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 49, 11), Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 28, 2)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 51, 21)) + + id: Id, +>id : Symbol(id, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 51, 46)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 51, 21)) + +): () => TagClass; +>Self : Symbol(Self, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 53, 4)) +>Shape : Symbol(Shape, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 53, 9)) +>TagClass : Symbol(TagClass, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 39, 1)) +>Self : Symbol(Self, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 53, 4)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 51, 21)) +>Shape : Symbol(Shape, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 53, 9)) + +class Foo extends Tag("Foo")< +>Foo : Symbol(Foo, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 53, 48)) +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 49, 11), Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 28, 2)) + + Foo, +>Foo : Symbol(Foo, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 53, 48)) + { + fn: (a: string) => Effect; +>fn : Symbol(fn, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 57, 3)) +>a : Symbol(a, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 58, 9)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 0, 36)) + } +>() {} + +layerEffect( +>layerEffect : Symbol(layerEffect, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 44, 1)) + + Foo, +>Foo : Symbol(Foo, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 53, 48)) + + effectGen(function* () { +>effectGen : Symbol(effectGen, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 6, 1)) + + return { + fn: effectFn(function* (a) { +>fn : Symbol(fn, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 65, 12)) +>effectFn : Symbol(effectFn, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 14, 2)) +>a : Symbol(a, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 66, 30)) + + a; // string +>a : Symbol(a, Decl(contextualParamTypeVsNestedReturnTypeInference3.ts, 66, 30)) + + }), + }; + }), +); + diff --git a/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference3.types b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference3.types new file mode 100644 index 0000000000000..8bad76cb403aa --- /dev/null +++ b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference3.types @@ -0,0 +1,189 @@ +//// [tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference3.ts] //// + +=== Performance Stats === +Type Count: 1,000 +Instantiation count: 2,500 + +=== contextualParamTypeVsNestedReturnTypeInference3.ts === +type Covariant = (_: never) => A; +>Covariant : Covariant +> : ^^^^^^^^^^^^ +>_ : never +> : ^^^^^ + +interface Effect { + readonly _A: Covariant; +>_A : Covariant +> : ^^^^^^^^^^^^ + + readonly _E: Covariant; +>_E : Covariant +> : ^^^^^^^^^^^^ + + readonly _R: Covariant; +>_R : Covariant +> : ^^^^^^^^^^^^ +} + +declare function effectGen, AEff>( +>effectGen : , AEff>(f: () => Generator) => Effect] ? E : never, [Eff] extends [Effect] ? R : never> +> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^ + + f: () => Generator, +>f : () => Generator +> : ^^^^^^ + +): Effect< + AEff, + [Eff] extends [Effect] ? E : never, + [Eff] extends [Effect] ? R : never +>; + +declare function effectFn< +>effectFn : , AEff, Args extends Array>(body: (...args: Args) => Generator) => (...args: Args) => Effect] ? E : never, [Eff] extends [Effect] ? R : never> +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ + + Eff extends Effect, + AEff, + Args extends Array, +>( + body: (...args: Args) => Generator, +>body : (...args: Args) => Generator +> : ^^^^ ^^ ^^^^^ +>args : Args +> : ^^^^ + +): ( + ...args: Args +>args : Args +> : ^^^^ + +) => Effect< + AEff, + [Eff] extends [Effect] ? E : never, + [Eff] extends [Effect] ? R : never +>; + +interface Tag { + readonly _op: "Tag"; +>_op : "Tag" +> : ^^^^^ + + readonly Service: Value; +>Service : Value +> : ^^^^^ + + readonly Identifier: Id; +>Identifier : Id +> : ^^ +} + +interface TagClassShape { + readonly Type: Shape; +>Type : Shape +> : ^^^^^ + + readonly Id: Id; +>Id : Id +> : ^^ +} + +interface TagClass extends Tag { + new (_: never): TagClassShape; +>_ : never +> : ^^^^^ + + readonly key: Id; +>key : Id +> : ^^ +} + +declare function layerEffect( +>layerEffect : (tag: Tag, effect: Effect) => unknown +> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^ + + tag: Tag, +>tag : Tag +> : ^^^^^^^^^ + + effect: Effect, +>effect : Effect +> : ^^^^^^^^^^^^^^^ + +): unknown; + +declare function Tag( +>Tag : (id: Id) => () => TagClass +> : ^^^^^^^ ^^^^^^^^^ ^^ ^^ ^^^^^ + + id: Id, +>id : Id +> : ^^ + +): () => TagClass; + +class Foo extends Tag("Foo")< +>Foo : Foo +> : ^^^ +>Tag("Foo")< Foo, { fn: (a: string) => Effect; }>() : TagClassShape<"Foo", { fn: (a: string) => Effect; }> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ +>Tag("Foo") : () => TagClass +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Tag : (id: Id) => () => TagClass +> : ^^^^^^^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>"Foo" : "Foo" +> : ^^^^^ + + Foo, + { + fn: (a: string) => Effect; +>fn : (a: string) => Effect +> : ^ ^^ ^^^^^ +>a : string +> : ^^^^^^ + } +>() {} + +layerEffect( +>layerEffect( Foo, effectGen(function* () { return { fn: effectFn(function* (a) { a; // string }), }; }),) : unknown +> : ^^^^^^^ +>layerEffect : (tag: Tag, effect: Effect) => unknown +> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^ + + Foo, +>Foo : typeof Foo +> : ^^^^^^^^^^ + + effectGen(function* () { +>effectGen(function* () { return { fn: effectFn(function* (a) { a; // string }), }; }) : Effect<{ fn: (a: string) => Effect; }, unknown, unknown> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>effectGen : , AEff>(f: () => Generator) => Effect] ? E : never, [Eff] extends [Effect] ? R : never> +> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^ +>function* () { return { fn: effectFn(function* (a) { a; // string }), }; } : () => Generator Effect; }, never> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + return { +>{ fn: effectFn(function* (a) { a; // string }), } : { fn: (a: string) => Effect; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + fn: effectFn(function* (a) { +>fn : (a: string) => Effect +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>effectFn(function* (a) { a; // string }) : (a: string) => Effect +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>effectFn : , AEff, Args extends Array>(body: (...args: Args) => Generator) => (...args: Args) => Effect] ? E : never, [Eff] extends [Effect] ? R : never> +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>function* (a) { a; // string } : (a: string) => Generator +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>a : string +> : ^^^^^^ + + a; // string +>a : string +> : ^^^^^^ + + }), + }; + }), +); + diff --git a/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference4.symbols b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference4.symbols new file mode 100644 index 0000000000000..47c49da15fbf1 --- /dev/null +++ b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference4.symbols @@ -0,0 +1,207 @@ +//// [tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference4.ts] //// + +=== contextualParamTypeVsNestedReturnTypeInference4.ts === +type Covariant = (_: never) => A; +>Covariant : Symbol(Covariant, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 0)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 15)) +>_ : Symbol(_, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 21)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 15)) + +interface Effect { +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 36)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 2, 17)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 2, 23)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 2, 38)) + + readonly _A: Covariant; +>_A : Symbol(Effect._A, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 2, 55)) +>Covariant : Symbol(Covariant, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 0)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 2, 17)) + + readonly _E: Covariant; +>_E : Symbol(Effect._E, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 3, 28)) +>Covariant : Symbol(Covariant, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 0)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 2, 23)) + + readonly _R: Covariant; +>_R : Symbol(Effect._R, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 4, 28)) +>Covariant : Symbol(Covariant, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 0)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 2, 38)) +} + +declare function effectGen( +>effectGen : Symbol(effectGen, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 6, 1)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 8, 27)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 8, 29)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 8, 32)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 8, 35)) + + f: () => Generator, AEff, never>, +>f : Symbol(f, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 8, 42)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 36)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 8, 27)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 8, 29)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 8, 32)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 8, 35)) + +): Effect; +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 36)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 8, 35)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 8, 29)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 8, 32)) + +declare function effectFn>( +>effectFn : Symbol(effectFn, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 10, 22)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 26)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 28)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 31)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 34)) +>Args : Symbol(Args, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 40)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) + + body: (...args: Args) => Generator, AEff, never>, +>body : Symbol(body, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 66)) +>args : Symbol(args, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 13, 9)) +>Args : Symbol(Args, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 40)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 36)) +>A : Symbol(A, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 26)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 28)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 31)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 34)) + +): (...args: Args) => Effect; +>args : Symbol(args, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 14, 4)) +>Args : Symbol(Args, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 40)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 36)) +>AEff : Symbol(AEff, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 34)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 28)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 12, 31)) + +interface Tag { +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 35, 11), Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 14, 41)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 16, 14)) +>Value : Symbol(Value, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 16, 24)) + + readonly _op: "Tag"; +>_op : Symbol(Tag._op, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 16, 40)) + + readonly Service: Value; +>Service : Symbol(Tag.Service, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 17, 22)) +>Value : Symbol(Value, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 16, 24)) + + readonly Identifier: Id; +>Identifier : Symbol(Tag.Identifier, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 18, 26)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 16, 14)) +} + +interface TagClassShape { +>TagClassShape : Symbol(TagClassShape, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 20, 1)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 22, 24), Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 23, 23)) +>Shape : Symbol(Shape, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 22, 27)) + + readonly Type: Shape; +>Type : Symbol(TagClassShape.Type, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 22, 36)) +>Shape : Symbol(Shape, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 22, 27)) + + readonly Id: Id; +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 22, 24), Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 23, 23)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 22, 24), Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 23, 23)) +} + +interface TagClass extends Tag { +>TagClass : Symbol(TagClass, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 25, 1)) +>Self : Symbol(Self, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 27, 19)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 27, 24)) +>Type : Symbol(Type, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 27, 43)) +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 35, 11), Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 14, 41)) +>Self : Symbol(Self, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 27, 19)) +>Type : Symbol(Type, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 27, 43)) + + new (_: never): TagClassShape; +>_ : Symbol(_, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 28, 7)) +>TagClassShape : Symbol(TagClassShape, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 20, 1)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 27, 24)) +>Type : Symbol(Type, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 27, 43)) + + readonly key: Id; +>key : Symbol(TagClass.key, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 28, 42)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 27, 24)) +} + +declare function layerEffect( +>layerEffect : Symbol(layerEffect, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 30, 1)) +>I : Symbol(I, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 32, 29)) +>S : Symbol(S, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 32, 31)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 32, 34)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 32, 37)) + + tag: Tag, +>tag : Symbol(tag, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 32, 41)) +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 35, 11), Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 14, 41)) +>I : Symbol(I, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 32, 29)) +>S : Symbol(S, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 32, 31)) + + effect: Effect, +>effect : Symbol(effect, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 33, 17)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 36)) +>S : Symbol(S, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 32, 31)) +>E : Symbol(E, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 32, 34)) +>R : Symbol(R, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 32, 37)) + +): unknown; + +declare function Tag( +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 35, 11), Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 14, 41)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 37, 21)) + + id: Id, +>id : Symbol(id, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 37, 46)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 37, 21)) + +): () => TagClass; +>Self : Symbol(Self, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 39, 4)) +>Shape : Symbol(Shape, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 39, 9)) +>TagClass : Symbol(TagClass, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 25, 1)) +>Self : Symbol(Self, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 39, 4)) +>Id : Symbol(Id, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 37, 21)) +>Shape : Symbol(Shape, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 39, 9)) + +class Foo extends Tag("Foo")< +>Foo : Symbol(Foo, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 39, 48)) +>Tag : Symbol(Tag, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 35, 11), Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 14, 41)) + + Foo, +>Foo : Symbol(Foo, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 39, 48)) + { + fn: (a: string) => Effect; +>fn : Symbol(fn, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 43, 3)) +>a : Symbol(a, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 44, 9)) +>Effect : Symbol(Effect, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 0, 36)) + } +>() {} + +layerEffect( +>layerEffect : Symbol(layerEffect, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 30, 1)) + + Foo, +>Foo : Symbol(Foo, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 39, 48)) + + effectGen(function* () { +>effectGen : Symbol(effectGen, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 6, 1)) + + return { + fn: effectFn(function* (a) { +>fn : Symbol(fn, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 51, 12)) +>effectFn : Symbol(effectFn, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 10, 22)) +>a : Symbol(a, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 52, 30)) + + a; // string +>a : Symbol(a, Decl(contextualParamTypeVsNestedReturnTypeInference4.ts, 52, 30)) + + }), + }; + }), +); + diff --git a/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference4.types b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference4.types new file mode 100644 index 0000000000000..b898b6a68fc34 --- /dev/null +++ b/tests/baselines/reference/contextualParamTypeVsNestedReturnTypeInference4.types @@ -0,0 +1,174 @@ +//// [tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference4.ts] //// + +=== Performance Stats === +Type Count: 1,000 +Instantiation count: 2,500 + +=== contextualParamTypeVsNestedReturnTypeInference4.ts === +type Covariant = (_: never) => A; +>Covariant : Covariant +> : ^^^^^^^^^^^^ +>_ : never +> : ^^^^^ + +interface Effect { + readonly _A: Covariant; +>_A : Covariant +> : ^^^^^^^^^^^^ + + readonly _E: Covariant; +>_E : Covariant +> : ^^^^^^^^^^^^ + + readonly _R: Covariant; +>_R : Covariant +> : ^^^^^^^^^^^^ +} + +declare function effectGen( +>effectGen : (f: () => Generator, AEff, never>) => Effect +> : ^ ^^ ^^ ^^ ^^ ^^ ^^^^^ + + f: () => Generator, AEff, never>, +>f : () => Generator, AEff, never> +> : ^^^^^^ + +): Effect; + +declare function effectFn>( +>effectFn : >(body: (...args: Args) => Generator, AEff, never>) => (...args: Args) => Effect +> : ^ ^^ ^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ + + body: (...args: Args) => Generator, AEff, never>, +>body : (...args: Args) => Generator, AEff, never> +> : ^^^^ ^^ ^^^^^ +>args : Args +> : ^^^^ + +): (...args: Args) => Effect; +>args : Args +> : ^^^^ + +interface Tag { + readonly _op: "Tag"; +>_op : "Tag" +> : ^^^^^ + + readonly Service: Value; +>Service : Value +> : ^^^^^ + + readonly Identifier: Id; +>Identifier : Id +> : ^^ +} + +interface TagClassShape { + readonly Type: Shape; +>Type : Shape +> : ^^^^^ + + readonly Id: Id; +>Id : Id +> : ^^ +} + +interface TagClass extends Tag { + new (_: never): TagClassShape; +>_ : never +> : ^^^^^ + + readonly key: Id; +>key : Id +> : ^^ +} + +declare function layerEffect( +>layerEffect : (tag: Tag, effect: Effect) => unknown +> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^ + + tag: Tag, +>tag : Tag +> : ^^^^^^^^^ + + effect: Effect, +>effect : Effect +> : ^^^^^^^^^^^^^^^ + +): unknown; + +declare function Tag( +>Tag : (id: Id) => () => TagClass +> : ^^^^^^^ ^^^^^^^^^ ^^ ^^ ^^^^^ + + id: Id, +>id : Id +> : ^^ + +): () => TagClass; + +class Foo extends Tag("Foo")< +>Foo : Foo +> : ^^^ +>Tag("Foo")< Foo, { fn: (a: string) => Effect; }>() : TagClassShape<"Foo", { fn: (a: string) => Effect; }> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ +>Tag("Foo") : () => TagClass +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Tag : (id: Id) => () => TagClass +> : ^^^^^^^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>"Foo" : "Foo" +> : ^^^^^ + + Foo, + { + fn: (a: string) => Effect; +>fn : (a: string) => Effect +> : ^ ^^ ^^^^^ +>a : string +> : ^^^^^^ + } +>() {} + +layerEffect( +>layerEffect( Foo, effectGen(function* () { return { fn: effectFn(function* (a) { a; // string }), }; }),) : unknown +> : ^^^^^^^ +>layerEffect : (tag: Tag, effect: Effect) => unknown +> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^ + + Foo, +>Foo : typeof Foo +> : ^^^^^^^^^^ + + effectGen(function* () { +>effectGen(function* () { return { fn: effectFn(function* (a) { a; // string }), }; }) : Effect<{ fn: (a: string) => Effect; }, unknown, unknown> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>effectGen : (f: () => Generator, AEff, never>) => Effect +> : ^ ^^ ^^ ^^ ^^ ^^ ^^^^^ +>function* () { return { fn: effectFn(function* (a) { a; // string }), }; } : () => Generator Effect; }, never> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + return { +>{ fn: effectFn(function* (a) { a; // string }), } : { fn: (a: string) => Effect; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + fn: effectFn(function* (a) { +>fn : (a: string) => Effect +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>effectFn(function* (a) { a; // string }) : (a: string) => Effect +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>effectFn : >(body: (...args: Args) => Generator, AEff, never>) => (...args: Args) => Effect +> : ^ ^^ ^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>function* (a) { a; // string } : (a: string) => Generator +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>a : string +> : ^^^^^^ + + a; // string +>a : string +> : ^^^^^^ + + }), + }; + }), +); + diff --git a/tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference1.ts b/tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference1.ts new file mode 100644 index 0000000000000..30b76dd33f986 --- /dev/null +++ b/tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference1.ts @@ -0,0 +1,34 @@ +// @strict: true +// @target: esnext +// @noEmit: true + +interface Effect { + _A: A; +} + +declare function effectGen(f: () => AEff): Effect; + +declare function effectFn>( + body: (...args: Args) => unknown, +): (...args: Args) => Effect; + +declare function layerEffect(tag: Tag, effect: Effect): unknown; + +interface Tag { + _Type: Type; +} + +declare const Foo: Tag<{ + fn: (a: string) => unknown; +}>; + +layerEffect( + Foo, + effectGen(function () { + return { + fn: effectFn(function (a) { + a; // string + }), + }; + }), +); diff --git a/tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference2.ts b/tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference2.ts new file mode 100644 index 0000000000000..fb8eeb0a503e4 --- /dev/null +++ b/tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference2.ts @@ -0,0 +1,92 @@ +// @strict: true +// @target: esnext +// @noEmit: true + +type Covariant = (_: never) => A; + +interface Effect { + readonly _A: Covariant; + readonly _E: Covariant; + readonly _R: Covariant; +} + +declare function effectGen, AEff>( + f: () => Generator +): Effect< + AEff, + [Eff] extends [never] + ? never + : [Eff] extends [Effect] + ? E + : never, + [Eff] extends [never] + ? never + : [Eff] extends [Effect] + ? R + : never +>; + +declare function effectFn< + Eff extends Effect, + AEff, + Args extends Array +>( + body: (...args: Args) => Generator +): ( + ...args: Args +) => Effect< + AEff, + [Eff] extends [never] + ? never + : [Eff] extends [Effect] + ? E + : never, + [Eff] extends [never] + ? never + : [Eff] extends [Effect] + ? R + : never +>; + +interface Tag { + readonly _op: "Tag"; + readonly Service: Value; + readonly Identifier: Id; +} + +interface TagClassShape { + readonly Type: Shape; + readonly Id: Id; +} + +interface TagClass extends Tag { + new (_: never): TagClassShape; + readonly key: Id; +} + +declare function layerEffect( + tag: Tag, + effect: Effect +): unknown; + +declare function Tag( + id: Id +): () => TagClass; + +class Foo extends Tag("Foo")< + Foo, + { + fn: (a: string) => Effect; + } +>() {} + +layerEffect( + Foo, + effectGen(function* () { + return { + fn: effectFn(function* (a) { + a; // string + }), + }; + }) +); diff --git a/tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference3.ts b/tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference3.ts new file mode 100644 index 0000000000000..8a0d653d5bbe8 --- /dev/null +++ b/tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference3.ts @@ -0,0 +1,76 @@ +// @strict: true +// @target: esnext +// @noEmit: true + +type Covariant = (_: never) => A; + +interface Effect { + readonly _A: Covariant; + readonly _E: Covariant; + readonly _R: Covariant; +} + +declare function effectGen, AEff>( + f: () => Generator, +): Effect< + AEff, + [Eff] extends [Effect] ? E : never, + [Eff] extends [Effect] ? R : never +>; + +declare function effectFn< + Eff extends Effect, + AEff, + Args extends Array, +>( + body: (...args: Args) => Generator, +): ( + ...args: Args +) => Effect< + AEff, + [Eff] extends [Effect] ? E : never, + [Eff] extends [Effect] ? R : never +>; + +interface Tag { + readonly _op: "Tag"; + readonly Service: Value; + readonly Identifier: Id; +} + +interface TagClassShape { + readonly Type: Shape; + readonly Id: Id; +} + +interface TagClass extends Tag { + new (_: never): TagClassShape; + readonly key: Id; +} + +declare function layerEffect( + tag: Tag, + effect: Effect, +): unknown; + +declare function Tag( + id: Id, +): () => TagClass; + +class Foo extends Tag("Foo")< + Foo, + { + fn: (a: string) => Effect; + } +>() {} + +layerEffect( + Foo, + effectGen(function* () { + return { + fn: effectFn(function* (a) { + a; // string + }), + }; + }), +); diff --git a/tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference4.ts b/tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference4.ts new file mode 100644 index 0000000000000..19a7f07f54bab --- /dev/null +++ b/tests/cases/compiler/contextualParamTypeVsNestedReturnTypeInference4.ts @@ -0,0 +1,62 @@ +// @strict: true +// @target: esnext +// @noEmit: true + +type Covariant = (_: never) => A; + +interface Effect { + readonly _A: Covariant; + readonly _E: Covariant; + readonly _R: Covariant; +} + +declare function effectGen( + f: () => Generator, AEff, never>, +): Effect; + +declare function effectFn>( + body: (...args: Args) => Generator, AEff, never>, +): (...args: Args) => Effect; + +interface Tag { + readonly _op: "Tag"; + readonly Service: Value; + readonly Identifier: Id; +} + +interface TagClassShape { + readonly Type: Shape; + readonly Id: Id; +} + +interface TagClass extends Tag { + new (_: never): TagClassShape; + readonly key: Id; +} + +declare function layerEffect( + tag: Tag, + effect: Effect, +): unknown; + +declare function Tag( + id: Id, +): () => TagClass; + +class Foo extends Tag("Foo")< + Foo, + { + fn: (a: string) => Effect; + } +>() {} + +layerEffect( + Foo, + effectGen(function* () { + return { + fn: effectFn(function* (a) { + a; // string + }), + }; + }), +);