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
Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+28-22
Original file line number
Diff line number
Diff line change
@@ -16893,10 +16893,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
16893
16893
}
16894
16894
16895
16895
function removeStringLiteralsMatchedByTemplateLiterals(types: Type[]) {
16896
-
const templates = filter(types, t =>
16897
-
!!(t.flags & TypeFlags.TemplateLiteral) &&
16898
-
isPatternLiteralType(t) &&
16899
-
(t as TemplateLiteralType).types.every(t => !(t.flags & TypeFlags.Intersection) || !areIntersectedTypesAvoidingPrimitiveReduction((t as IntersectionType).types))) as TemplateLiteralType[];
16896
+
const templates = filter(types, t => !!(t.flags & TypeFlags.TemplateLiteral) && isPatternLiteralType(t)) as TemplateLiteralType[];
16900
16897
if (templates.length) {
16901
16898
let i = types.length;
16902
16899
while (i > 0) {
@@ -17407,20 +17404,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
17407
17404
return reduceLeft(types, (n, t) => n + getConstituentCount(t), 0);
Copy file name to clipboardExpand all lines: tests/baselines/reference/templateLiteralTypesPatterns.errors.txt
+7-3
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ templateLiteralTypesPatterns.ts(129,9): error TS2345: Argument of type '"1.1e-10
55
55
templateLiteralTypesPatterns.ts(140,1): error TS2322: Type '`a${string}`' is not assignable to type '`a${number}`'.
56
56
templateLiteralTypesPatterns.ts(141,1): error TS2322: Type '"bno"' is not assignable to type '`a${any}`'.
57
57
templateLiteralTypesPatterns.ts(160,7): error TS2322: Type '"anything"' is not assignable to type '`${number} ${number}`'.
58
-
templateLiteralTypesPatterns.ts(211,5): error TS2345: Argument of type '"abcTest"' is not assignable to parameter of type '`${`a${string}` & `${string}a`}Test`'.
58
+
templateLiteralTypesPatterns.ts(215,5): error TS2345: Argument of type '"abcTest"' is not assignable to parameter of type '`${`a${string}` & `${string}a`}Test`'.
0 commit comments