Skip to content

Commit

Permalink
Ignore template literal types which contain intersections in removeSt…
Browse files Browse the repository at this point in the history
…ringLiteralsMatchedByTemplateLiterals
  • Loading branch information
jakebailey committed Mar 21, 2023
1 parent b168b24 commit fbc0ccc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16339,7 +16339,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}

function removeStringLiteralsMatchedByTemplateLiterals(types: Type[]) {
const templates = filter(types, t => !!(t.flags & TypeFlags.TemplateLiteral) && isPatternLiteralType(t)) as TemplateLiteralType[];
// Skip TemplateLiteralTypes which contain intersections; plain string literals can never match these.
const templates = filter(types, t => !!(t.flags & TypeFlags.TemplateLiteral) && isPatternLiteralType(t) && !some((t as TemplateLiteralType).types, t2 => !!(t2.flags & TypeFlags.Intersection))) as TemplateLiteralType[];
if (templates.length) {
let i = types.length;
while (i > 0) {
Expand Down

0 comments on commit fbc0ccc

Please sign in to comment.