mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
Reinstate constraint check for template literal types (#43661)
* Add missing constraint check for template literal types * Add regression test
This commit is contained in:
@@ -18420,6 +18420,16 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else if (source.flags & TypeFlags.TemplateLiteral) {
|
||||
if (!(target.flags & TypeFlags.TemplateLiteral)) {
|
||||
const baseConstraint = getBaseConstraintOfType(source);
|
||||
const constraint = baseConstraint && baseConstraint !== source ? baseConstraint : stringType;
|
||||
if (result = isRelatedTo(constraint, target, reportErrors)) {
|
||||
resetErrorInfo(saveErrorInfo);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (source.flags & TypeFlags.StringMapping) {
|
||||
if (target.flags & TypeFlags.StringMapping && (<StringMappingType>source).symbol === (<StringMappingType>target).symbol) {
|
||||
if (result = isRelatedTo((<StringMappingType>source).type, (<StringMappingType>target).type, reportErrors)) {
|
||||
|
||||
Reference in New Issue
Block a user