From cad3041c0cccc951cdf6f6ca2be2bb1e30b30020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 26 Aug 2024 19:37:30 +0200 Subject: [PATCH] Add a test for constraint of an infer type parameter not being fully instantiated previously --- ...WithExtendsDependingOnTypeVariables.symbols | 18 ++++++++++++++++++ ...esWithExtendsDependingOnTypeVariables.types | 13 +++++++++++++ ...TypesWithExtendsDependingOnTypeVariables.ts | 7 +++++++ 3 files changed, 38 insertions(+) create mode 100644 tests/baselines/reference/inferTypesWithExtendsDependingOnTypeVariables.symbols create mode 100644 tests/baselines/reference/inferTypesWithExtendsDependingOnTypeVariables.types create mode 100644 tests/cases/conformance/types/conditional/inferTypesWithExtendsDependingOnTypeVariables.ts diff --git a/tests/baselines/reference/inferTypesWithExtendsDependingOnTypeVariables.symbols b/tests/baselines/reference/inferTypesWithExtendsDependingOnTypeVariables.symbols new file mode 100644 index 0000000000000..20a17c8c279af --- /dev/null +++ b/tests/baselines/reference/inferTypesWithExtendsDependingOnTypeVariables.symbols @@ -0,0 +1,18 @@ +//// [tests/cases/conformance/types/conditional/inferTypesWithExtendsDependingOnTypeVariables.ts] //// + +=== inferTypesWithExtendsDependingOnTypeVariables.ts === +// repro from https://github.com/microsoft/TypeScript/issues/54197 + +type Bar = T extends readonly [any, ...infer X extends readonly K[]] ? X : never; +>Bar : Symbol(Bar, Decl(inferTypesWithExtendsDependingOnTypeVariables.ts, 0, 0)) +>K : Symbol(K, Decl(inferTypesWithExtendsDependingOnTypeVariables.ts, 2, 9)) +>T : Symbol(T, Decl(inferTypesWithExtendsDependingOnTypeVariables.ts, 2, 11)) +>T : Symbol(T, Decl(inferTypesWithExtendsDependingOnTypeVariables.ts, 2, 11)) +>X : Symbol(X, Decl(inferTypesWithExtendsDependingOnTypeVariables.ts, 2, 77)) +>K : Symbol(K, Decl(inferTypesWithExtendsDependingOnTypeVariables.ts, 2, 9)) +>X : Symbol(X, Decl(inferTypesWithExtendsDependingOnTypeVariables.ts, 2, 77)) + +type Res1 = Bar<"a" | "b", ["a", "b", "b"]> +>Res1 : Symbol(Res1, Decl(inferTypesWithExtendsDependingOnTypeVariables.ts, 2, 114)) +>Bar : Symbol(Bar, Decl(inferTypesWithExtendsDependingOnTypeVariables.ts, 0, 0)) + diff --git a/tests/baselines/reference/inferTypesWithExtendsDependingOnTypeVariables.types b/tests/baselines/reference/inferTypesWithExtendsDependingOnTypeVariables.types new file mode 100644 index 0000000000000..d891ae6597fca --- /dev/null +++ b/tests/baselines/reference/inferTypesWithExtendsDependingOnTypeVariables.types @@ -0,0 +1,13 @@ +//// [tests/cases/conformance/types/conditional/inferTypesWithExtendsDependingOnTypeVariables.ts] //// + +=== inferTypesWithExtendsDependingOnTypeVariables.ts === +// repro from https://github.com/microsoft/TypeScript/issues/54197 + +type Bar = T extends readonly [any, ...infer X extends readonly K[]] ? X : never; +>Bar : Bar +> : ^^^^^^^^^ + +type Res1 = Bar<"a" | "b", ["a", "b", "b"]> +>Res1 : ["b", "b"] +> : ^^^^^^^^^^ + diff --git a/tests/cases/conformance/types/conditional/inferTypesWithExtendsDependingOnTypeVariables.ts b/tests/cases/conformance/types/conditional/inferTypesWithExtendsDependingOnTypeVariables.ts new file mode 100644 index 0000000000000..9deb9e41f1cc3 --- /dev/null +++ b/tests/cases/conformance/types/conditional/inferTypesWithExtendsDependingOnTypeVariables.ts @@ -0,0 +1,7 @@ +// @strict: true +// @noEmit: true + +// repro from https://github.com/microsoft/TypeScript/issues/54197 + +type Bar = T extends readonly [any, ...infer X extends readonly K[]] ? X : never; +type Res1 = Bar<"a" | "b", ["a", "b", "b"]>