tstyche 3.3.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/build/tstyche.js +17 -10
  2. package/package.json +1 -1
package/build/tstyche.js CHANGED
@@ -3474,15 +3474,13 @@ class MatchWorker {
3474
3474
  return this.#checkIsRelatedTo(sourceNode, targetNode, relation);
3475
3475
  }
3476
3476
  #checkIsRelatedTo(sourceNode, targetNode, relation) {
3477
- const sourceType = this.getType(sourceNode);
3478
- const targetType = this.getType(targetNode);
3479
- let result = this.#typeChecker.isTypeRelatedTo(sourceType, targetType, relation);
3480
- if (!result &&
3481
- relation === this.#typeChecker.relation.identity &&
3482
- (sourceType.isIntersection() || sourceType.isUnion())) {
3483
- result = sourceType.types.every((type) => this.#typeChecker.isTypeRelatedTo(type, targetType, relation));
3484
- }
3485
- return result;
3477
+ const sourceType = relation === this.#typeChecker.relation.identity
3478
+ ? this.#trySimplifyType(this.getType(sourceNode))
3479
+ : this.getType(sourceNode);
3480
+ const targetType = relation === this.#typeChecker.relation.identity
3481
+ ? this.#trySimplifyType(this.getType(targetNode))
3482
+ : this.getType(targetNode);
3483
+ return this.#typeChecker.isTypeRelatedTo(sourceType, targetType, relation);
3486
3484
  }
3487
3485
  extendsObjectType(type) {
3488
3486
  const nonPrimitiveType = { flags: this.#compiler.TypeFlags.NonPrimitive };
@@ -3550,6 +3548,15 @@ class MatchWorker {
3550
3548
  }
3551
3549
  return DiagnosticOrigin.fromNode(enclosingNode, this.assertion);
3552
3550
  }
3551
+ #trySimplifyType(type) {
3552
+ if (type.isIntersection() || type.isUnion()) {
3553
+ const candidateType = type.types[0];
3554
+ if (type.types.every((type) => this.#typeChecker.isTypeRelatedTo(type, candidateType, this.#typeChecker.relation.identity))) {
3555
+ return candidateType;
3556
+ }
3557
+ }
3558
+ return type;
3559
+ }
3553
3560
  }
3554
3561
 
3555
3562
  class PrimitiveTypeMatcher {
@@ -4327,7 +4334,7 @@ class TaskRunner {
4327
4334
  class Runner {
4328
4335
  #eventEmitter = new EventEmitter();
4329
4336
  #resolvedConfig;
4330
- static version = "3.3.0";
4337
+ static version = "3.3.1";
4331
4338
  constructor(resolvedConfig) {
4332
4339
  this.#resolvedConfig = resolvedConfig;
4333
4340
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tstyche",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "The Essential Type Testing Tool.",
5
5
  "keywords": [
6
6
  "typescript",