Skip to content

Commit aac8961

Browse files
committed
Move check
1 parent c978136 commit aac8961

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/compiler/checker.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17928,14 +17928,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1792817928
}
1792917929

1793017930
function getTemplateLiteralType(texts: readonly string[], types: readonly Type[]): Type {
17931-
if (texts.length === 2 && texts[0] === "" && texts[1] === ""
17932-
// literals (including string enums) are stringified below
17933-
&& !(types[0].flags & TypeFlags.Literal)
17934-
// infer T extends StringLike can't be unwrapped eagerly
17935-
&& !types[0].symbol?.declarations?.some(d => d.parent.kind === SyntaxKind.InferType)
17936-
&& isTypeAssignableTo(types[0], stringType)) {
17937-
return types[0];
17938-
}
1793917931
const unionIndex = findIndex(types, t => !!(t.flags & (TypeFlags.Never | TypeFlags.Union)));
1794017932
if (unionIndex >= 0) {
1794117933
return checkCrossProductUnion(types) ?
@@ -17945,6 +17937,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1794517937
if (contains(types, wildcardType)) {
1794617938
return wildcardType;
1794717939
}
17940+
if (
17941+
texts.length === 2 && texts[0] === "" && texts[1] === ""
17942+
// literals (including string enums) are stringified below
17943+
&& !(types[0].flags & TypeFlags.Literal)
17944+
// infer T extends StringLike can't be unwrapped eagerly
17945+
&& !types[0].symbol?.declarations?.some(d => d.parent.kind === SyntaxKind.InferType)
17946+
&& isTypeAssignableTo(types[0], stringType)
17947+
) {
17948+
return types[0];
17949+
}
1794817950
const newTypes: Type[] = [];
1794917951
const newTexts: string[] = [];
1795017952
let text = texts[0];

0 commit comments

Comments
 (0)