Fix crash in union subtype reduction involving template literal and string mapping types (#52699)

This commit is contained in:
Anders Hejlsberg
2023-02-09 15:04:57 -08:00
committed by GitHub
parent 6c9792aa87
commit bd905d4936
6 changed files with 25 additions and 1 deletions

View File

@@ -16124,7 +16124,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
function removeStringLiteralsMatchedByTemplateLiterals(types: Type[]) {
const templates = filter(types, isPatternLiteralType) as TemplateLiteralType[];
const templates = filter(types, t => !!(t.flags & TypeFlags.TemplateLiteral) && isPatternLiteralType(t)) as TemplateLiteralType[];
if (templates.length) {
let i = types.length;
while (i > 0) {