You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (includes & TypeFlags.IncludesConstrainedTypeVariable) {
@@ -17442,18 +17448,19 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
17442
17448
}
17443
17449
17444
17450
/**
17445
-
* Returns `true` if the intersection of the template literals and string literals is the empty set, eg `get${string}` & "setX", and should reduce to `never`
17451
+
* Returns true if the intersection of the template literals and string literals is the empty set,
17452
+
* for example `get${string}` & "setX", and should reduce to never.
17446
17453
*/
17447
17454
function extractRedundantTemplateLiterals(types: Type[]): boolean {
17448
17455
let i = types.length;
17449
17456
const literals = filter(types, t => !!(t.flags & TypeFlags.StringLiteral));
17450
17457
while (i > 0) {
17451
17458
i--;
17452
17459
const t = types[i];
17453
-
if (!(t.flags & TypeFlags.TemplateLiteral)) continue;
17460
+
if (!(t.flags & (TypeFlags.TemplateLiteral | TypeFlags.StringMapping))) continue;
17454
17461
for (const t2 of literals) {
17455
17462
if (isTypeSubtypeOf(t2, t)) {
17456
-
// eg, ``get${T}` & "getX"` is just `"getX"`
17463
+
// For example, `get${T}` & "getX" is just "getX", and Lowercase<string> & "foo" is just "foo"
17457
17464
orderedRemoveItemAt(types, i);
17458
17465
break;
17459
17466
}
@@ -17563,7 +17570,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
17563
17570
) {
17564
17571
return neverType;
17565
17572
}
17566
-
if (includes & TypeFlags.TemplateLiteral && includes & TypeFlags.StringLiteral && extractRedundantTemplateLiterals(typeSet)) {
17573
+
if (includes & (TypeFlags.TemplateLiteral | TypeFlags.StringMapping) && includes & TypeFlags.StringLiteral && extractRedundantTemplateLiterals(typeSet)) {
0 commit comments