tstyche 3.3.0 → 3.4.0

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.
package/build/index.d.cts CHANGED
@@ -216,26 +216,26 @@ interface Expect {
216
216
  /**
217
217
  * Builds an assertion.
218
218
  *
219
- * @template Source - The type against which the assertion will be made.
219
+ * @template Source - The type against which the assertion is made.
220
220
  */
221
221
  <Source>(): Modifier;
222
222
  /**
223
223
  * Builds an assertion.
224
224
  *
225
- * @param source - The expression against which type the assertion will be made.
225
+ * @param source - The expression against which type the assertion is made.
226
226
  */
227
227
  (source: unknown): Modifier;
228
228
  fail: {
229
229
  /**
230
230
  * Mark an assertion as supposed to fail.
231
231
  *
232
- * @template Source - The type against which the assertion will be made.
232
+ * @template Source - The type against which the assertion is made.
233
233
  */
234
234
  <Source>(): Modifier;
235
235
  /**
236
236
  * Mark an assertion as supposed to fail.
237
237
  *
238
- * @param source - The expression against which type the assertion will be made.
238
+ * @param source - The expression against which type the assertion is made.
239
239
  */
240
240
  (source: unknown): Modifier;
241
241
  };
@@ -246,26 +246,26 @@ interface Expect {
246
246
  /**
247
247
  * Marks an assertion as focused.
248
248
  *
249
- * @template Source - The type against which the assertion will be made.
249
+ * @template Source - The type against which the assertion is made.
250
250
  */
251
251
  <Source>(): Modifier;
252
252
  /**
253
253
  * Marks an assertion as focused.
254
254
  *
255
- * @param source - The expression against which type the assertion will be made.
255
+ * @param source - The expression against which type the assertion is made.
256
256
  */
257
257
  (source: unknown): Modifier;
258
258
  fail: {
259
259
  /**
260
260
  * Mark an assertion as supposed to fail.
261
261
  *
262
- * @template Source - The type against which the assertion will be made.
262
+ * @template Source - The type against which the assertion is made.
263
263
  */
264
264
  <Source>(): Modifier;
265
265
  /**
266
266
  * Mark an assertion as supposed to fail.
267
267
  *
268
- * @param source - The expression against which type the assertion will be made.
268
+ * @param source - The expression against which type the assertion is made.
269
269
  */
270
270
  (source: unknown): Modifier;
271
271
  };
@@ -277,26 +277,26 @@ interface Expect {
277
277
  /**
278
278
  * Marks an assertion as skipped.
279
279
  *
280
- * @template Source - The type against which the assertion will be made.
280
+ * @template Source - The type against which the assertion is made.
281
281
  */
282
282
  <Source>(): Modifier;
283
283
  /**
284
284
  * Marks an assertion as skipped.
285
285
  *
286
- * @param source - The expression against which type the assertion will be made.
286
+ * @param source - The expression against which type the assertion is made.
287
287
  */
288
288
  (source: unknown): Modifier;
289
289
  fail: {
290
290
  /**
291
291
  * Marks an assertion as supposed to fail.
292
292
  *
293
- * @template Source - The type against which the assertion will be made.
293
+ * @template Source - The type against which the assertion is made.
294
294
  */
295
295
  <Source>(): Modifier;
296
296
  /**
297
297
  * Marks an assertion as supposed to fail.
298
298
  *
299
- * @param source - The expression against which type the assertion will be made.
299
+ * @param source - The expression against which type the assertion is made.
300
300
  */
301
301
  (source: unknown): Modifier;
302
302
  };
package/build/index.d.ts CHANGED
@@ -216,26 +216,26 @@ interface Expect {
216
216
  /**
217
217
  * Builds an assertion.
218
218
  *
219
- * @template Source - The type against which the assertion will be made.
219
+ * @template Source - The type against which the assertion is made.
220
220
  */
221
221
  <Source>(): Modifier;
222
222
  /**
223
223
  * Builds an assertion.
224
224
  *
225
- * @param source - The expression against which type the assertion will be made.
225
+ * @param source - The expression against which type the assertion is made.
226
226
  */
227
227
  (source: unknown): Modifier;
228
228
  fail: {
229
229
  /**
230
230
  * Mark an assertion as supposed to fail.
231
231
  *
232
- * @template Source - The type against which the assertion will be made.
232
+ * @template Source - The type against which the assertion is made.
233
233
  */
234
234
  <Source>(): Modifier;
235
235
  /**
236
236
  * Mark an assertion as supposed to fail.
237
237
  *
238
- * @param source - The expression against which type the assertion will be made.
238
+ * @param source - The expression against which type the assertion is made.
239
239
  */
240
240
  (source: unknown): Modifier;
241
241
  };
@@ -246,26 +246,26 @@ interface Expect {
246
246
  /**
247
247
  * Marks an assertion as focused.
248
248
  *
249
- * @template Source - The type against which the assertion will be made.
249
+ * @template Source - The type against which the assertion is made.
250
250
  */
251
251
  <Source>(): Modifier;
252
252
  /**
253
253
  * Marks an assertion as focused.
254
254
  *
255
- * @param source - The expression against which type the assertion will be made.
255
+ * @param source - The expression against which type the assertion is made.
256
256
  */
257
257
  (source: unknown): Modifier;
258
258
  fail: {
259
259
  /**
260
260
  * Mark an assertion as supposed to fail.
261
261
  *
262
- * @template Source - The type against which the assertion will be made.
262
+ * @template Source - The type against which the assertion is made.
263
263
  */
264
264
  <Source>(): Modifier;
265
265
  /**
266
266
  * Mark an assertion as supposed to fail.
267
267
  *
268
- * @param source - The expression against which type the assertion will be made.
268
+ * @param source - The expression against which type the assertion is made.
269
269
  */
270
270
  (source: unknown): Modifier;
271
271
  };
@@ -277,26 +277,26 @@ interface Expect {
277
277
  /**
278
278
  * Marks an assertion as skipped.
279
279
  *
280
- * @template Source - The type against which the assertion will be made.
280
+ * @template Source - The type against which the assertion is made.
281
281
  */
282
282
  <Source>(): Modifier;
283
283
  /**
284
284
  * Marks an assertion as skipped.
285
285
  *
286
- * @param source - The expression against which type the assertion will be made.
286
+ * @param source - The expression against which type the assertion is made.
287
287
  */
288
288
  (source: unknown): Modifier;
289
289
  fail: {
290
290
  /**
291
291
  * Marks an assertion as supposed to fail.
292
292
  *
293
- * @template Source - The type against which the assertion will be made.
293
+ * @template Source - The type against which the assertion is made.
294
294
  */
295
295
  <Source>(): Modifier;
296
296
  /**
297
297
  * Marks an assertion as supposed to fail.
298
298
  *
299
- * @param source - The expression against which type the assertion will be made.
299
+ * @param source - The expression against which type the assertion is made.
300
300
  */
301
301
  (source: unknown): Modifier;
302
302
  };
package/build/tstyche.js CHANGED
@@ -2841,26 +2841,28 @@ class WatchService {
2841
2841
  cancellationToken.cancel(reason);
2842
2842
  debounce.resolveWith([]);
2843
2843
  };
2844
- const onInput = (chunk) => {
2845
- switch (chunk.toLowerCase()) {
2846
- case "\u0003":
2847
- case "\u0004":
2848
- case "\u001B":
2849
- case "q":
2850
- case "x":
2851
- onClose(CancellationReason.WatchClose);
2852
- break;
2853
- case "\u000D":
2854
- case "\u0020":
2855
- case "a":
2856
- debounce.clearTimeout();
2857
- if (this.#watchedTestFiles.size > 0) {
2858
- debounce.resolveWith([...this.#watchedTestFiles.values()]);
2859
- }
2860
- break;
2861
- }
2862
- };
2863
- this.#inputService = new InputService(onInput);
2844
+ if (!environmentOptions.noInteractive) {
2845
+ const onInput = (chunk) => {
2846
+ switch (chunk.toLowerCase()) {
2847
+ case "\u0003":
2848
+ case "\u0004":
2849
+ case "\u001B":
2850
+ case "q":
2851
+ case "x":
2852
+ onClose(CancellationReason.WatchClose);
2853
+ break;
2854
+ case "\u000D":
2855
+ case "\u0020":
2856
+ case "a":
2857
+ debounce.clearTimeout();
2858
+ if (this.#watchedTestFiles.size > 0) {
2859
+ debounce.resolveWith([...this.#watchedTestFiles.values()]);
2860
+ }
2861
+ break;
2862
+ }
2863
+ };
2864
+ this.#inputService = new InputService(onInput);
2865
+ }
2864
2866
  const onChangedFile = (filePath) => {
2865
2867
  debounce.refreshTimeout();
2866
2868
  let task = this.#watchedTestFiles.get(filePath);
@@ -3474,15 +3476,13 @@ class MatchWorker {
3474
3476
  return this.#checkIsRelatedTo(sourceNode, targetNode, relation);
3475
3477
  }
3476
3478
  #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;
3479
+ const sourceType = relation === this.#typeChecker.relation.identity
3480
+ ? this.#simplifyType(this.getType(sourceNode))
3481
+ : this.getType(sourceNode);
3482
+ const targetType = relation === this.#typeChecker.relation.identity
3483
+ ? this.#simplifyType(this.getType(targetNode))
3484
+ : this.getType(targetNode);
3485
+ return this.#typeChecker.isTypeRelatedTo(sourceType, targetType, relation);
3486
3486
  }
3487
3487
  extendsObjectType(type) {
3488
3488
  const nonPrimitiveType = { flags: this.#compiler.TypeFlags.NonPrimitive };
@@ -3511,7 +3511,7 @@ class MatchWorker {
3511
3511
  return this.#typeChecker.typeToString(type);
3512
3512
  }
3513
3513
  getType(node) {
3514
- return this.#compiler.isExpression(node) ? this.#getTypeOfNode(node) : this.#getTypeOfTypeNode(node);
3514
+ return this.#compiler.isTypeNode(node) ? this.#getTypeOfTypeNode(node) : this.#getTypeOfNode(node);
3515
3515
  }
3516
3516
  #getTypeOfNode(node) {
3517
3517
  let type = this.#typeCache.get(node);
@@ -3550,6 +3550,15 @@ class MatchWorker {
3550
3550
  }
3551
3551
  return DiagnosticOrigin.fromNode(enclosingNode, this.assertion);
3552
3552
  }
3553
+ #simplifyType(type) {
3554
+ if (type.isUnionOrIntersection()) {
3555
+ const candidateType = this.#simplifyType(type.types[0]);
3556
+ if (type.types.every((type) => this.#typeChecker.isTypeRelatedTo(this.#simplifyType(type), candidateType, this.#typeChecker.relation.identity))) {
3557
+ return candidateType;
3558
+ }
3559
+ }
3560
+ return type;
3561
+ }
3553
3562
  }
3554
3563
 
3555
3564
  class PrimitiveTypeMatcher {
@@ -4327,11 +4336,15 @@ class TaskRunner {
4327
4336
  class Runner {
4328
4337
  #eventEmitter = new EventEmitter();
4329
4338
  #resolvedConfig;
4330
- static version = "3.3.0";
4339
+ static version = "3.4.0";
4331
4340
  constructor(resolvedConfig) {
4332
4341
  this.#resolvedConfig = resolvedConfig;
4333
4342
  }
4334
4343
  async #addReporters() {
4344
+ if (this.#resolvedConfig.watch && !environmentOptions.noInteractive) {
4345
+ const watchReporter = new WatchReporter(this.#resolvedConfig);
4346
+ this.#eventEmitter.addReporter(watchReporter);
4347
+ }
4335
4348
  for (const reporter of this.#resolvedConfig.reporters) {
4336
4349
  switch (reporter) {
4337
4350
  case "list": {
@@ -4351,10 +4364,6 @@ class Runner {
4351
4364
  }
4352
4365
  }
4353
4366
  }
4354
- if (this.#resolvedConfig.watch) {
4355
- const watchReporter = new WatchReporter(this.#resolvedConfig);
4356
- this.#eventEmitter.addReporter(watchReporter);
4357
- }
4358
4367
  }
4359
4368
  async run(testFiles, cancellationToken = new CancellationToken()) {
4360
4369
  const tasks = testFiles.map((testFile) => (testFile instanceof Task ? testFile : new Task(testFile)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tstyche",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "The Essential Type Testing Tool.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -63,17 +63,17 @@
63
63
  "devDependencies": {
64
64
  "@biomejs/biome": "1.9.4",
65
65
  "@rollup/plugin-typescript": "12.1.2",
66
- "@types/node": "22.10.2",
67
- "@types/react": "19.0.2",
66
+ "@types/node": "22.10.5",
67
+ "@types/react": "19.0.4",
68
68
  "ajv": "8.17.1",
69
69
  "cspell": "8.17.1",
70
70
  "magic-string": "0.30.17",
71
71
  "monocart-coverage-reports": "2.11.5",
72
72
  "pretty-ansi": "3.0.0",
73
- "rollup": "4.29.1",
73
+ "rollup": "4.30.1",
74
74
  "rollup-plugin-dts": "6.1.1",
75
75
  "tslib": "2.8.1",
76
- "typescript": "5.7.2"
76
+ "typescript": "5.7.3"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "typescript": "4.x || 5.x"