Skip to content

Commit e68e177

Browse files
committed
Try out new thing for all relations
1 parent 53f60d1 commit e68e177

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/compiler/checker.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -20719,6 +20719,18 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2071920719
if (source === target) {
2072020720
return true;
2072120721
}
20722+
// TODO(jakebailey): just trying this out; passes all tests and is interesting
20723+
if (
20724+
source.flags & TypeFlags.Literal
20725+
&& (source.flags & TypeFlags.Literal) === (target.flags & TypeFlags.Literal)
20726+
&& !(source.flags & TypeFlags.EnumLiteral && target.flags & TypeFlags.EnumLiteral)
20727+
) {
20728+
if (source.flags & TypeFlags.BooleanLiteral) {
20729+
return source === target;
20730+
}
20731+
return (source as LiteralType).value === (target as LiteralType).value;
20732+
}
20733+
2072220734
if (relation !== identityRelation) {
2072320735
if (relation === comparableRelation && !(target.flags & TypeFlags.Never) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) {
2072420736
return true;
@@ -28245,7 +28257,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2824528257

2824628258
// Avoid going through relations for comparison between literals of the same types;
2824728259
// if they're not equal then they're not related and we can skip doing a bunch of work.
28248-
if (t.flags & TypeFlags.Literal && (t.flags & TypeFlags.Literal) === (c.flags & TypeFlags.Literal)) {
28260+
if (
28261+
t.flags & TypeFlags.Literal
28262+
&& (t.flags & TypeFlags.Literal) === (c.flags & TypeFlags.Literal)
28263+
&& !(t.flags & TypeFlags.EnumLiteral && c.flags & TypeFlags.EnumLiteral)
28264+
) {
2824928265
if (t.flags & TypeFlags.BooleanLiteral) {
2825028266
const tIsTrue = t === trueType || t === regularTrueType;
2825128267
const cIsTrue = c === trueType || c === regularTrueType;

0 commit comments

Comments
 (0)