@systemfsoftware/stryker-js-typescript-checker 7.1.1 → 7.1.2

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 (3) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/main.mjs +538 -38
  3. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @systemfsoftware/stryker-js-typescript-checker
2
2
 
3
+ ## 7.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Mutants are now type-checked incrementally. Checking a mutant costs its own file and the files that import it — through a relative path, a path alias, or a re-export — instead of a full type check of every project the checker opens, so a run whose mutants all live in one file finishes instead of staying at zero completed mutants until the run is killed.
8
+
9
+ A mutation that breaks a file which imports the mutated file is still a `CompileError` rather than being handed to the test runner.
10
+
11
+ - Updated dependencies:
12
+ - @systemfsoftware/stryker-js-plugin-interface@9.0.0
13
+
3
14
  ## 7.1.1
4
15
 
5
16
  ### Patch Changes
package/dist/main.mjs CHANGED
@@ -12512,7 +12512,7 @@ const flatten$2 = /*#__PURE__*/ flatMap$6(identity);
12512
12512
  * @category combining
12513
12513
  * @since 2.0.0
12514
12514
  */
12515
- const all$2 = (input) => {
12515
+ const all$3 = (input) => {
12516
12516
  if (Symbol.iterator in input) {
12517
12517
  const out = [];
12518
12518
  for (const o of input) {
@@ -13841,6 +13841,12 @@ const isArrayNonEmpty$1 = (self) => self.length > 0;
13841
13841
  * @internal
13842
13842
  */
13843
13843
  const normalize$1 = (n) => n > 0 ? Math.floor(n) : 0;
13844
+ /**
13845
+ * Normalizes a collection count to an integer greater than or equal to `1`.
13846
+ *
13847
+ * @internal
13848
+ */
13849
+ const normalizeNonEmpty = (n) => Math.max(1, normalize$1(n));
13844
13850
  //#endregion
13845
13851
  //#region ../../node_modules/.pnpm/effect@4.0.0-rc.117/node_modules/effect/dist/Result.js
13846
13852
  /**
@@ -14290,7 +14296,7 @@ const flatMap$5 = /*#__PURE__*/ dual(2, (self, f) => isFailure(self) ? fail$6(se
14290
14296
  * @category sequencing
14291
14297
  * @since 2.0.0
14292
14298
  */
14293
- const all$1 = (input) => {
14299
+ const all$2 = (input) => {
14294
14300
  if (Symbol.iterator in input) {
14295
14301
  const out = [];
14296
14302
  for (const e of input) {
@@ -14672,6 +14678,29 @@ const fromIterable$5 = (collection) => Array$1.isArray(collection) ? collection
14672
14678
  */
14673
14679
  const ensure = (self) => Array$1.isArray(self) ? self : [self];
14674
14680
  /**
14681
+ * Adds a single element to the front of an iterable, returning a `NonEmptyArray`.
14682
+ *
14683
+ * **When to use**
14684
+ *
14685
+ * Use when you need to guarantee a non-empty result after adding a required
14686
+ * leading value.
14687
+ *
14688
+ * **Example** (Prepending an element)
14689
+ *
14690
+ * ```ts import.meta.vitest
14691
+ * import { Array } from "effect"
14692
+ *
14693
+ * Array.prepend([2, 3, 4], 1) // => [1, 2, 3, 4]
14694
+ * ```
14695
+ *
14696
+ * @see {@link append} — add to the end
14697
+ * @see {@link prependAll} — prepend multiple elements
14698
+ *
14699
+ * @category combining
14700
+ * @since 2.0.0
14701
+ */
14702
+ const prepend = /*#__PURE__*/ dual(2, (self, head) => [head, ...self]);
14703
+ /**
14675
14704
  * Adds a single element to the end of an iterable, returning a `NonEmptyArray`.
14676
14705
  *
14677
14706
  * **When to use**
@@ -15241,6 +15270,145 @@ const zipWith$3 = /*#__PURE__*/ dual(3, (self, that, f) => {
15241
15270
  }
15242
15271
  return [];
15243
15272
  });
15273
+ /**
15274
+ * Applies a function repeatedly to consume prefixes of the array and collect
15275
+ * the values it produces.
15276
+ *
15277
+ * **When to use**
15278
+ *
15279
+ * Use when you need custom grouping logic where each step returns both a value
15280
+ * and the remaining input.
15281
+ *
15282
+ * **Details**
15283
+ *
15284
+ * The function receives a `NonEmptyReadonlyArray` and returns `[value, rest]`.
15285
+ * Processing continues until the remaining array is empty.
15286
+ *
15287
+ * **Example** (Chopping an array)
15288
+ *
15289
+ * ```ts import.meta.vitest
15290
+ * import { Array } from "effect"
15291
+ *
15292
+ * Array.chop([1, 2, 3, 4, 5], (as): [number, Array<number>] => [as[0] * 2, as.slice(1)]) // => [2, 4, 6, 8, 10]
15293
+ * ```
15294
+ *
15295
+ * @see {@link chunksOf} — split into fixed-size chunks
15296
+ * @see {@link splitAt} — split at an index
15297
+ *
15298
+ * @category splitting
15299
+ * @since 2.0.0
15300
+ */
15301
+ const chop = /*#__PURE__*/ dual(2, (self, f) => {
15302
+ const input = fromIterable$5(self);
15303
+ if (isReadonlyArrayNonEmpty(input)) {
15304
+ const [b, rest] = f(input);
15305
+ const out = [b];
15306
+ let next = rest;
15307
+ while (isArrayNonEmpty$1(next)) {
15308
+ const [b, rest] = f(next);
15309
+ out.push(b);
15310
+ next = rest;
15311
+ }
15312
+ return out;
15313
+ }
15314
+ return [];
15315
+ });
15316
+ /**
15317
+ * Splits a non-empty array into two parts at the given index. The first part
15318
+ * is guaranteed to be non-empty (`n` is clamped to >= 1).
15319
+ *
15320
+ * **When to use**
15321
+ *
15322
+ * Use when downstream code requires the left side of the split to contain at
15323
+ * least one element.
15324
+ *
15325
+ * **Details**
15326
+ *
15327
+ * `n` is rounded down and clamped to `[1, length]`. `NaN` is treated as `1`.
15328
+ *
15329
+ * **Example** (Splitting a non-empty array)
15330
+ *
15331
+ * ```ts import.meta.vitest
15332
+ * import { Array } from "effect"
15333
+ *
15334
+ * Array.splitAtNonEmpty(["a", "b", "c", "d", "e"], 3) // => [["a", "b", "c"], ["d", "e"]]
15335
+ * ```
15336
+ *
15337
+ * @see {@link splitAt} — for possibly-empty arrays
15338
+ *
15339
+ * @category splitting
15340
+ * @since 4.0.0
15341
+ */
15342
+ const splitAtNonEmpty = /*#__PURE__*/ dual(2, (self, n) => {
15343
+ const _n = normalizeNonEmpty(n);
15344
+ return _n >= self.length ? [copy$1(self), []] : [prepend(self.slice(1, _n), headNonEmpty(self)), self.slice(_n)];
15345
+ });
15346
+ /**
15347
+ * Creates a shallow copy of an array.
15348
+ *
15349
+ * **When to use**
15350
+ *
15351
+ * Use to create a distinct array reference for an existing array, for example
15352
+ * before mutating the returned array.
15353
+ *
15354
+ * **Details**
15355
+ *
15356
+ * The return type preserves `NonEmptyArray`. Use this when you need a distinct
15357
+ * reference, for example before mutating the returned array.
15358
+ *
15359
+ * **Example** (Copying an array)
15360
+ *
15361
+ * ```ts import.meta.vitest
15362
+ * import { Array } from "effect"
15363
+ *
15364
+ * const original = [1, 2, 3]
15365
+ * const copied = Array.copy(original)
15366
+ *
15367
+ * copied // => [1, 2, 3]
15368
+ * original === copied // => false
15369
+ * ```
15370
+ *
15371
+ * @see {@link fromIterable} — returns the same reference for arrays
15372
+ *
15373
+ * @category transforming
15374
+ * @since 2.0.0
15375
+ */
15376
+ const copy$1 = (self) => self.slice();
15377
+ /**
15378
+ * Splits an iterable into chunks of length `n`. The last chunk may be shorter
15379
+ * if `n` does not evenly divide the length.
15380
+ *
15381
+ * **When to use**
15382
+ *
15383
+ * Use to divide an iterable into a new array of non-overlapping chunks with a
15384
+ * maximum chunk size.
15385
+ *
15386
+ * **Details**
15387
+ *
15388
+ * `n` is rounded down and normalized to at least `1`; `NaN` and non-positive
15389
+ * values therefore produce singleton chunks. `chunksOf(n)([])` is `[]`, not
15390
+ * `[[]]`. Each chunk is a `NonEmptyArray`, and the outer return type preserves
15391
+ * `NonEmptyArray`.
15392
+ *
15393
+ * **Example** (Chunking an array)
15394
+ *
15395
+ * ```ts import.meta.vitest
15396
+ * import { Array } from "effect"
15397
+ *
15398
+ * Array.chunksOf([1, 2, 3, 4, 5], 2) // => [[1, 2], [3, 4], [5]]
15399
+ * ```
15400
+ *
15401
+ * @see {@link split} — split into a given number of groups
15402
+ * @see {@link window} — sliding windows
15403
+ *
15404
+ * @category splitting
15405
+ * @since 2.0.0
15406
+ */
15407
+ const chunksOf = /*#__PURE__*/ dual(2, (self, n) => {
15408
+ const input = fromIterable$5(self);
15409
+ if (isReadonlyArrayNonEmpty(input)) return chop(input, splitAtNonEmpty(n));
15410
+ return [];
15411
+ });
15244
15412
  const hashBucketsAdd = (buckets, value) => {
15245
15413
  const hash$8 = hash(value);
15246
15414
  const bucket = buckets.get(hash$8);
@@ -17284,7 +17452,7 @@ const provideService$1 = function() {
17284
17452
  };
17285
17453
  const provideServiceImpl = (self, service, implementation) => updateContext$1(self, add$3(service, implementation));
17286
17454
  /** @internal */
17287
- const zipWith$2 = /*#__PURE__*/ dual((args) => isEffect$1(args[1]), (self, that, f, options) => options?.concurrent ? map$4(all([self, that], { concurrency: 2 }), ([a, a2]) => internalCall(() => f(a, a2))) : flatMap$3(self, (a) => map$4(that, (a2) => internalCall(() => f(a, a2)))));
17455
+ const zipWith$2 = /*#__PURE__*/ dual((args) => isEffect$1(args[1]), (self, that, f, options) => options?.concurrent ? map$4(all$1([self, that], { concurrency: 2 }), ([a, a2]) => internalCall(() => f(a, a2))) : flatMap$3(self, (a) => map$4(that, (a2) => internalCall(() => f(a, a2)))));
17288
17456
  /** @internal */
17289
17457
  const forever$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, options) => whileLoop$1({
17290
17458
  while: constTrue,
@@ -17647,7 +17815,7 @@ const uninterruptibleMask = (f) => withFiber$1((fiber) => {
17647
17815
  return f(interruptible$1);
17648
17816
  });
17649
17817
  /** @internal */
17650
- const all = (arg, options) => {
17818
+ const all$1 = (arg, options) => {
17651
17819
  if (isIterable(arg)) return options?.mode === "result" ? forEach$2(arg, result$2, options) : forEach$2(arg, identity, options);
17652
17820
  else if (options?.discard) return options.mode === "result" ? forEach$2(Object.values(arg), result$2, options) : forEach$2(Object.values(arg), identity, options);
17653
17821
  return suspend$3(() => {
@@ -21380,6 +21548,119 @@ function addAttributesToContext(context, attributes) {
21380
21548
  */
21381
21549
  const isEffect = isEffect$1;
21382
21550
  /**
21551
+ * Combines an iterable or record of effects into one effect whose success shape
21552
+ * follows the input.
21553
+ *
21554
+ * **When to use**
21555
+ *
21556
+ * Use to run a known collection of effects and collect results in the same
21557
+ * tuple, iterable, or record shape.
21558
+ *
21559
+ * **Details**
21560
+ *
21561
+ * Tuple and iterable inputs collect results in order. Record inputs collect
21562
+ * results under the same keys. By default, the combined effect fails on the
21563
+ * first failure; with concurrent execution, effects that have already started
21564
+ * may be interrupted, while effects not yet started are skipped.
21565
+ *
21566
+ * Options:
21567
+ *
21568
+ * Use `concurrency` to control sequential or concurrent execution. Use
21569
+ * `mode: "result"` to run every effect and collect each success or failure as a
21570
+ * `Result` in the same output shape. Use `discard: true` to ignore successful
21571
+ * values and return `void`.
21572
+ *
21573
+ * **Example** (Collecting tuple results in order)
21574
+ *
21575
+ * ```ts import.meta.vitest
21576
+ * import { Effect } from "effect"
21577
+ *
21578
+ * const tupleOfEffects = [
21579
+ * Effect.succeed(42),
21580
+ * Effect.succeed("Hello")
21581
+ * ] as const
21582
+ *
21583
+ * // ┌─── Effect<[number, string], never, never>
21584
+ * // ▼
21585
+ * const resultsAsTuple = Effect.all(tupleOfEffects)
21586
+ *
21587
+ * await Effect.runPromise(resultsAsTuple) // => [42, "Hello"]
21588
+ * ```
21589
+ *
21590
+ * **Example** (Collecting iterable results in order)
21591
+ *
21592
+ * ```ts import.meta.vitest
21593
+ * import { Effect } from "effect"
21594
+ *
21595
+ * const iterableOfEffects: Iterable<Effect.Effect<number>> = [1, 2, 3].map(
21596
+ * Effect.succeed
21597
+ * )
21598
+ *
21599
+ * // ┌─── Effect<number[], never, never>
21600
+ * // ▼
21601
+ * const resultsAsArray = Effect.all(iterableOfEffects)
21602
+ *
21603
+ * await Effect.runPromise(resultsAsArray) // => [1, 2, 3]
21604
+ * ```
21605
+ *
21606
+ * **Example** (Collecting struct results by key)
21607
+ *
21608
+ * ```ts import.meta.vitest
21609
+ * import { Effect } from "effect"
21610
+ *
21611
+ * const structOfEffects = {
21612
+ * a: Effect.succeed(42),
21613
+ * b: Effect.succeed("Hello")
21614
+ * }
21615
+ *
21616
+ * // ┌─── Effect<{ a: number; b: string; }, never, never>
21617
+ * // ▼
21618
+ * const resultsAsStruct = Effect.all(structOfEffects)
21619
+ *
21620
+ * await Effect.runPromise(resultsAsStruct) // => { a: 42, b: "Hello" }
21621
+ * ```
21622
+ *
21623
+ * **Example** (Collecting record results by key)
21624
+ *
21625
+ * ```ts import.meta.vitest
21626
+ * import { Effect } from "effect"
21627
+ *
21628
+ * const recordOfEffects: Record<string, Effect.Effect<number>> = {
21629
+ * key1: Effect.succeed(1),
21630
+ * key2: Effect.succeed(2)
21631
+ * }
21632
+ *
21633
+ * // ┌─── Effect<{ [x: string]: number; }, never, never>
21634
+ * // ▼
21635
+ * const resultsAsRecord = Effect.all(recordOfEffects)
21636
+ *
21637
+ * await Effect.runPromise(resultsAsRecord) // => { key1: 1, key2: 2 }
21638
+ * ```
21639
+ *
21640
+ * **Example** (Stopping on the first failure)
21641
+ *
21642
+ * ```ts import.meta.vitest
21643
+ * import { Effect, Exit } from "effect"
21644
+ * const output: Array<unknown> = []
21645
+ * const record = (value: unknown) => Effect.sync(() => { output.push(value) })
21646
+ *
21647
+ * const program = Effect.all([
21648
+ * Effect.succeed("Task1").pipe(Effect.tap(record)),
21649
+ * Effect.fail("Task2: Oh no!").pipe(Effect.tap(record)),
21650
+ * // Won't execute due to earlier failure
21651
+ * Effect.succeed("Task3").pipe(Effect.tap(record))
21652
+ * ])
21653
+ *
21654
+ * const outcome = await Effect.runPromiseExit(program)
21655
+ * const observation = [output, outcome] // => [["Task1"], Exit.fail("Task2: Oh no!")]
21656
+ * ```
21657
+ *
21658
+ * @see {@link forEach} for iterating over elements and applying an effect.
21659
+ * @category collecting
21660
+ * @since 2.0.0
21661
+ */
21662
+ const all = all$1;
21663
+ /**
21383
21664
  * Executes an effectful operation for each element in an `Iterable`.
21384
21665
  *
21385
21666
  * **When to use**
@@ -32247,6 +32528,13 @@ const isArrays = /*#__PURE__*/ makeGuard("Arrays");
32247
32528
  */
32248
32529
  const isObjects = /*#__PURE__*/ makeGuard("Objects");
32249
32530
  /**
32531
+ * Narrows an {@link AST} to {@link Union}.
32532
+ *
32533
+ * @category guards
32534
+ * @since 3.10.0
32535
+ */
32536
+ const isUnion = /*#__PURE__*/ makeGuard("Union");
32537
+ /**
32250
32538
  * Narrows an {@link AST} to {@link Suspend}.
32251
32539
  *
32252
32540
  * @category guards
@@ -33914,10 +34202,10 @@ function extractStructuralChecks(checks) {
33914
34202
  * @category transforming
33915
34203
  * @since 4.0.0
33916
34204
  */
33917
- const toType = /*#__PURE__*/ memoizeIdempotent((ast) => {
33918
- if (ast.encoding) return toType(replaceEncoding(ast, void 0));
34205
+ const toType$1 = /*#__PURE__*/ memoizeIdempotent((ast) => {
34206
+ if (ast.encoding) return toType$1(replaceEncoding(ast, void 0));
33919
34207
  const out = ast;
33920
- const type = out.recur?.(toType) ?? out;
34208
+ const type = out.recur?.(toType$1) ?? out;
33921
34209
  const encodingChecks = type.encodingChecks;
33922
34210
  if (encodingChecks) {
33923
34211
  const checks = type === ast ? encodingChecks : isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0 ? extractStructuralChecks(encodingChecks) : void 0;
@@ -33955,7 +34243,7 @@ const toType = /*#__PURE__*/ memoizeIdempotent((ast) => {
33955
34243
  * @since 4.0.0
33956
34244
  */
33957
34245
  const toEncoded$1 = /*#__PURE__*/ memoizeIdempotent((ast) => {
33958
- return toType(flip(ast));
34246
+ return toType$1(flip(ast));
33959
34247
  });
33960
34248
  function flipEncoding(ast, encoding) {
33961
34249
  const links = encoding;
@@ -34359,7 +34647,7 @@ function makeEffect(schema) {
34359
34647
  const ast = schema.ast;
34360
34648
  let parser;
34361
34649
  return (input, options) => {
34362
- return (parser ??= runWithCompiler(constructorCompiler, toType(ast)))(input, options?.disableChecks ? options?.parseOptions ? {
34650
+ return (parser ??= runWithCompiler(constructorCompiler, toType$1(ast)))(input, options?.disableChecks ? options?.parseOptions ? {
34363
34651
  ...options.parseOptions,
34364
34652
  disableChecks: true
34365
34653
  } : { disableChecks: true } : options?.parseOptions);
@@ -34418,7 +34706,7 @@ function makeOption(schema) {
34418
34706
  * @since 4.0.0
34419
34707
  */
34420
34708
  function make$19(schema) {
34421
- return makeConstructorSync(toType(schema.ast));
34709
+ return makeConstructorSync(toType$1(schema.ast));
34422
34710
  }
34423
34711
  /**
34424
34712
  * Creates a type guard that checks whether an input satisfies the schema's decoded
@@ -34459,7 +34747,7 @@ function makeIs(ast) {
34459
34747
  }
34460
34748
  /** @internal */
34461
34749
  function _is(ast) {
34462
- const typeAST = toType(ast);
34750
+ const typeAST = toType$1(ast);
34463
34751
  let guard = (input) => {
34464
34752
  guard = makeIs(typeAST);
34465
34753
  return guard(input);
@@ -36371,6 +36659,14 @@ const optional = /*#__PURE__*/ lambda((self) => {
36371
36659
  return make$14(optional$1(self.ast), { schema });
36372
36660
  });
36373
36661
  /**
36662
+ * Extracts the type-side schema: sets `Encoded` to equal the decoded `Type`,
36663
+ * discarding the encoding transformation path.
36664
+ *
36665
+ * @category transforming
36666
+ * @since 4.0.0
36667
+ */
36668
+ const toType = /*#__PURE__*/ lambda((schema) => make$14(toType$1(schema.ast), { schema }));
36669
+ /**
36374
36670
  * Extracts the encoded-side schema: sets `Type` to equal the `Encoded`,
36375
36671
  * discarding the decoding transformation path.
36376
36672
  *
@@ -36994,6 +37290,145 @@ function TaggedStruct(value, fields) {
36994
37290
  });
36995
37291
  }
36996
37292
  /**
37293
+ * Augments an existing {@link Union} of tagged structs with utility methods and an ordered tuple of discriminant
37294
+ * values.
37295
+ *
37296
+ * **Gotchas**
37297
+ *
37298
+ * Throws if multiple members use the same discriminant property key.
37299
+ *
37300
+ * **Example** (Adding tagged-union utilities to an existing union)
37301
+ *
37302
+ * ```ts import.meta.vitest
37303
+ * import { Schema } from "effect"
37304
+ *
37305
+ * const A = Schema.TaggedStruct("A", { value: Schema.Number })
37306
+ * const B = Schema.TaggedStruct("B", { name: Schema.String })
37307
+ *
37308
+ * const MyUnion = Schema.Union([A, B]).pipe(Schema.toTaggedUnion("_tag"))
37309
+ *
37310
+ * // Pattern-match on the union
37311
+ * const result = MyUnion.match({ _tag: "A", value: 1 }, {
37312
+ * A: (a) => `number: ${a.value}`,
37313
+ * B: (b) => `name: ${b.name}`
37314
+ * })
37315
+ * result // => "number: 1"
37316
+ * ```
37317
+ *
37318
+ * @see {@link TaggedUnion} for a shorthand that builds the union from scratch
37319
+ * @category combinators
37320
+ * @since 4.0.0
37321
+ */
37322
+ function toTaggedUnion(tag) {
37323
+ return (self) => {
37324
+ const cases = {};
37325
+ const discriminants = [];
37326
+ const discriminantKeys = /* @__PURE__ */ new Set();
37327
+ const guards = {};
37328
+ const isAnyOf = (keys) => (value) => keys.includes(value[tag]);
37329
+ walk(self);
37330
+ return Object.assign(self, {
37331
+ cases,
37332
+ discriminants,
37333
+ isAnyOf,
37334
+ guards,
37335
+ match,
37336
+ matchOrElse
37337
+ });
37338
+ function walk(schema) {
37339
+ const ast = schema.ast;
37340
+ if (isUnion(ast) && "members" in schema && globalThis.Array.isArray(schema.members) && schema.members.every(isSchema)) return schema.members.forEach(walk);
37341
+ const sentinels = collectSentinels(ast);
37342
+ if (sentinels.length > 0) {
37343
+ const literal = sentinels.find((s) => s.key === tag)?.literal;
37344
+ if (isPropertyKey(literal)) {
37345
+ const key = typeof literal === "number" ? globalThis.String(literal) : literal;
37346
+ if (discriminantKeys.has(key)) throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(literal)}`);
37347
+ discriminantKeys.add(key);
37348
+ discriminants.push(literal);
37349
+ assignProperty$1(cases, literal, schema);
37350
+ assignProperty$1(guards, literal, is$1(toType(schema)));
37351
+ return;
37352
+ }
37353
+ }
37354
+ throw new globalThis.Error("No literal or unique symbol found");
37355
+ }
37356
+ function match() {
37357
+ if (arguments.length === 1) {
37358
+ const cases = arguments[0];
37359
+ return function(value) {
37360
+ const key = value[tag];
37361
+ return (Object.hasOwn(cases, key) ? cases[key] : void 0)(value);
37362
+ };
37363
+ }
37364
+ const value = arguments[0];
37365
+ const cases = arguments[1];
37366
+ const key = value[tag];
37367
+ return (Object.hasOwn(cases, key) ? cases[key] : void 0)(value);
37368
+ }
37369
+ function matchOrElse() {
37370
+ if (arguments.length === 2) {
37371
+ const cases = arguments[0];
37372
+ const orElse = arguments[1];
37373
+ return function(value) {
37374
+ const key = value[tag];
37375
+ return (Object.hasOwn(cases, key) ? cases[key] ?? orElse : orElse)(value);
37376
+ };
37377
+ }
37378
+ const value = arguments[0];
37379
+ const cases = arguments[1];
37380
+ const orElse = arguments[2];
37381
+ const key = value[tag];
37382
+ return (Object.hasOwn(cases, key) ? cases[key] ?? orElse : orElse)(value);
37383
+ }
37384
+ };
37385
+ }
37386
+ /**
37387
+ * Builds a discriminated union from a record of field sets, one per variant.
37388
+ * Each key becomes the `_tag` literal and the value is passed to {@link TaggedStruct}.
37389
+ * The result includes `cases`, `guards`, `isAnyOf`, `match`, and `matchOrElse` utilities.
37390
+ *
37391
+ * **Example** (Pattern matching a discriminated union)
37392
+ *
37393
+ * ```ts import.meta.vitest
37394
+ * import { Schema } from "effect"
37395
+ *
37396
+ * const Shape = Schema.TaggedUnion({
37397
+ * Circle: { radius: Schema.Number },
37398
+ * Rectangle: { width: Schema.Number, height: Schema.Number }
37399
+ * })
37400
+ *
37401
+ * // Pattern-match on a decoded value
37402
+ * const area = Shape.match({ _tag: "Circle", radius: 5 }, {
37403
+ * Circle: (c) => Math.PI * c.radius ** 2,
37404
+ * Rectangle: (r) => r.width * r.height
37405
+ * })
37406
+ * Math.round(area * 100) / 100 // => 78.54
37407
+ * ```
37408
+ *
37409
+ * @see {@link toTaggedUnion} to augment an existing union instead
37410
+ * @category constructors
37411
+ * @since 4.0.0
37412
+ */
37413
+ function TaggedUnion(casesByTag) {
37414
+ const cases = {};
37415
+ const members = [];
37416
+ for (const key of Object.keys(casesByTag)) {
37417
+ const member = TaggedStruct(key, casesByTag[key]);
37418
+ assignProperty$1(cases, key, member);
37419
+ members.push(member);
37420
+ }
37421
+ const union = Union(members);
37422
+ const { guards, isAnyOf, match, matchOrElse } = toTaggedUnion("_tag")(union);
37423
+ return make$14(union.ast, {
37424
+ cases,
37425
+ isAnyOf,
37426
+ guards,
37427
+ match,
37428
+ matchOrElse
37429
+ });
37430
+ }
37431
+ /**
36997
37432
  * Constructs an `SchemaAST.Link` that describes how a value of type `T` encodes to and decodes from a `To` schema.
36998
37433
  * Used when building low-level AST transformations that bridge two schema types.
36999
37434
  *
@@ -57562,7 +57997,7 @@ const closePath = (stack, context, visitors) => match$1(isCommentKey(context.key
57562
57997
  onFalse: () => notify(visitors.exit, stack.pop())
57563
57998
  });
57564
57999
  const parentOf = (stack) => getOrNull(last(stack));
57565
- const notify = (visitor, path) => match$6(all$2({
58000
+ const notify = (visitor, path) => match$6(all$3({
57566
58001
  visitor: fromNullishOr(visitor),
57567
58002
  path: fromNullishOr(path)
57568
58003
  }), {
@@ -61329,7 +61764,7 @@ const transformInto = (request) => transform(request.ast, request.collector, {
61329
61764
  message: `Failed to transform ${request.file.name}`,
61330
61765
  cause
61331
61766
  })));
61332
- const collectMutants = (collector) => flatMap$1(sync(() => all$1(collector.map(toApiMutant))), (collected) => isSuccess$1(collected) ? succeed$2(collected.success) : fail$2(InstrumentError.make({
61767
+ const collectMutants = (collector) => flatMap$1(sync(() => all$2(collector.map(toApiMutant))), (collected) => isSuccess$1(collected) ? succeed$2(collected.success) : fail$2(InstrumentError.make({
61333
61768
  message: "Failed to instrument",
61334
61769
  cause: collected.failure
61335
61770
  })));
@@ -61705,6 +62140,10 @@ const Percentage = Finite.pipe(check$1(isBetween({
61705
62140
  minimum: 0,
61706
62141
  maximum: 100
61707
62142
  })));
62143
+ const MutationScore = TaggedUnion({
62144
+ Scored: { percentage: Percentage },
62145
+ Unscored: {}
62146
+ });
61708
62147
  var Metrics = class Metrics extends Class("Metrics")({
61709
62148
  pending: NonNegativeInt,
61710
62149
  killed: NonNegativeInt,
@@ -61734,10 +62173,10 @@ var Metrics = class Metrics extends Class("Metrics")({
61734
62173
  return this.totalValid + this.totalInvalid + this.ignored + this.pending;
61735
62174
  }
61736
62175
  get mutationScore() {
61737
- return Math.min(100, Math.max(0, this.totalDetected / this.totalValid * 100));
62176
+ return scoreOf(this.totalDetected, this.totalValid);
61738
62177
  }
61739
62178
  get mutationScoreBasedOnCoveredCode() {
61740
- return Math.min(100, Math.max(0, this.totalDetected / this.totalCovered * 100));
62179
+ return scoreOf(this.totalDetected, this.totalCovered);
61741
62180
  }
61742
62181
  static fromMutants(mutants) {
61743
62182
  return Metrics.make({
@@ -61753,6 +62192,10 @@ var Metrics = class Metrics extends Class("Metrics")({
61753
62192
  }
61754
62193
  };
61755
62194
  const metricCountOf = (mutants, status) => mutants.filter((mutant) => mutant.status === status).length;
62195
+ const scoreOf = (detected, counted) => match$1(counted > 0, {
62196
+ onTrue: () => MutationScore.cases.Scored.make({ percentage: detected / counted * 100 }),
62197
+ onFalse: () => MutationScore.cases.Unscored.make({})
62198
+ });
61756
62199
  const MetricsResultSchema = Struct({
61757
62200
  name: String$2,
61758
62201
  metrics: Metrics,
@@ -62995,6 +63438,7 @@ var TsConfigNotFoundError = class extends TaggedError()("TsConfigNotFoundError",
62995
63438
  return `The tsconfig file does not exist at: "${this.file}". Please configure the tsconfig file in your stryker.conf file using "tsconfigFile"`;
62996
63439
  }
62997
63440
  };
63441
+ const PathAliasesSchema = Record(String$2, ArraySchema(String$2));
62998
63442
  const TsConfigSchema = Struct({
62999
63443
  references: optional(ArraySchema(Struct({ path: String$2 }))),
63000
63444
  compilerOptions: optional(Record(String$2, Unknown))
@@ -63180,6 +63624,7 @@ const make$1 = dual(2, (options, services) => {
63180
63624
  nodes: empty$4(),
63181
63625
  lastMutants: [],
63182
63626
  lastMutatedFileNames: [],
63627
+ aliases: [],
63183
63628
  allTSConfigFiles: fromIterable([tsconfigFile]),
63184
63629
  tsconfigFile
63185
63630
  };
@@ -63312,6 +63757,12 @@ const referencedProjectsOf = (rt, config, fromDirName) => map$5(config.reference
63312
63757
  onFalse: () => rt.pathService.join(resolved, "tsconfig.json")
63313
63758
  }));
63314
63759
  });
63760
+ const aliasEntriesOf = (compilerOptions) => Object.entries(getOrElse$1(flatMap$6(fromUndefinedOr(compilerOptions), (options) => decodeUnknownOption(PathAliasesSchema)(options["paths"])), () => ({})));
63761
+ const pathAliasesOf = (pathService, fileName, config) => aliasEntriesOf(config.compilerOptions ?? {}).map(([pattern, targets]) => ({
63762
+ pattern,
63763
+ targets,
63764
+ baseDir: pathService.dirname(fileName)
63765
+ }));
63315
63766
  const recordTsConfig = (rt, buildMode, walk, fileName, jsonText) => match$4(parseTsConfig(fileName, jsonText), {
63316
63767
  onFailure: () => ({
63317
63768
  ...walk,
@@ -63319,6 +63770,7 @@ const recordTsConfig = (rt, buildMode, walk, fileName, jsonText) => match$4(pars
63319
63770
  }),
63320
63771
  onSuccess: (config) => ({
63321
63772
  overrides: set$4(walk.overrides, fileName, overrideOptions(config, buildMode)),
63773
+ aliases: [...walk.aliases, ...pathAliasesOf(rt.pathService, fileName, config)],
63322
63774
  files: reduce(referencedProjectsOf(rt, config, rt.pathService.dirname(fileName)), walk.files, (files, referenced) => add(files, normalizeFileName(referenced))),
63323
63775
  processed: walk.processed
63324
63776
  })
@@ -63378,22 +63830,23 @@ const annotateDiagnosticSample = (diagnostics) => match$1(diagnostics.length ===
63378
63830
  onTrue: () => void_$1,
63379
63831
  onFalse: () => annotateCurrentSpan({ "typescript.diagnostics.sample": map$5(take$2(diagnostics, 10), (diagnostic) => diagnostic.fileName + ":" + diagnostic.code + ": " + diagnostic.text).join("; ") })
63380
63832
  });
63381
- const importSpecifierOf = (statement, sourceFile) => match$1(statement.kind !== SyntaxKind.ImportDeclaration, {
63382
- onTrue: () => none(),
63383
- onFalse: () => {
63833
+ const carriesModuleSpecifier = (statement) => statement.kind === SyntaxKind.ImportDeclaration || statement.kind === SyntaxKind.ExportDeclaration;
63834
+ const moduleSpecifierOf = (statement, sourceFile) => match$1(carriesModuleSpecifier(statement), {
63835
+ onTrue: () => {
63384
63836
  const children = [];
63385
63837
  statement.forEachChild((child) => {
63386
63838
  children.push(child);
63387
63839
  });
63388
63840
  return map$8(findLast(children, (child) => child.kind === SyntaxKind.StringLiteral), (literal) => literal.getText(sourceFile));
63389
- }
63841
+ },
63842
+ onFalse: () => none()
63390
63843
  });
63391
63844
  const keepSome = (option) => match$6(option, {
63392
63845
  onNone: () => failVoid,
63393
63846
  onSome: succeed$6
63394
63847
  });
63395
63848
  const importsOf = (sourceFile) => [
63396
- ...filterMap(sourceFile.statements, (statement) => keepSome(importSpecifierOf(statement, sourceFile))),
63849
+ ...filterMap(sourceFile.statements, (statement) => keepSome(moduleSpecifierOf(statement, sourceFile))),
63397
63850
  ...map$5(sourceFile.referencedFiles, (reference) => reference.fileName),
63398
63851
  ...map$5(sourceFile.typeReferenceDirectives, (reference) => reference.fileName)
63399
63852
  ];
@@ -63432,10 +63885,25 @@ const resolutionCandidates = (rt, resolved) => {
63432
63885
  }
63433
63886
  });
63434
63887
  };
63888
+ const prefixOf = (pattern) => pattern.slice(0, Math.max(0, pattern.indexOf("*")));
63889
+ const suffixOf = (pattern) => pattern.slice(pattern.indexOf("*") + 1);
63890
+ const stripPrefix = (specifier, prefix) => map$8(liftPredicate(specifier, (candidate) => candidate.startsWith(prefix)), (candidate) => candidate.slice(prefix.length));
63891
+ const stripSuffix = (specifier, suffix) => map$8(liftPredicate(specifier, (candidate) => candidate.endsWith(suffix)), (candidate) => candidate.slice(0, candidate.length - suffix.length));
63892
+ const exactCaptureOf = (alias, specifier) => map$8(liftPredicate(specifier, (candidate) => candidate === alias.pattern), () => "");
63893
+ const wildcardCaptureOf = (alias, specifier) => flatMap$6(stripPrefix(specifier, prefixOf(alias.pattern)), (rest) => stripSuffix(rest, suffixOf(alias.pattern)));
63894
+ const captureOf = (alias, specifier) => match$1(alias.pattern.includes("*"), {
63895
+ onTrue: () => wildcardCaptureOf(alias, specifier),
63896
+ onFalse: () => exactCaptureOf(alias, specifier)
63897
+ });
63898
+ const aliasTargetPaths = (rt, aliases, specifier) => flatMap$4(aliases, (alias) => match$6(captureOf(alias, specifier), {
63899
+ onNone: () => [],
63900
+ onSome: (capture) => map$5(alias.targets, (target) => normalizeFileName(rt.pathService.resolve(alias.baseDir, target.replace("*", capture))))
63901
+ }));
63902
+ const resolveAliasedSpecifier = (rt, sourceFiles, specifier) => firstSomeOf(map$5(aliasTargetPaths(rt, getUnsafe(rt.state).aliases, specifier), (target) => findFirst(resolutionCandidates(rt, target), (candidate) => has$5(sourceFiles, candidate))));
63435
63903
  const resolveSpecifier = (rt, sourceFiles, fileName, specifier) => {
63436
63904
  const cleaned = specifier.replace(CLEAN_SPECIFIER_PATTERN, "");
63437
63905
  return match$1(relativeSpecifierPattern.test(cleaned), {
63438
- onFalse: () => none(),
63906
+ onFalse: () => resolveAliasedSpecifier(rt, sourceFiles, cleaned),
63439
63907
  onTrue: () => {
63440
63908
  const resolved = normalizeFileName(rt.pathService.resolve(rt.pathService.dirname(fileName), cleaned));
63441
63909
  return filter$1(findFirst(resolutionCandidates(rt, resolved), (candidate) => has$5(sourceFiles, candidate)), (candidate) => candidate !== "");
@@ -63593,12 +64061,14 @@ const init = (self) => {
63593
64061
  const walk = yield* walkTsConfigs(rt, buildMode, {
63594
64062
  files: fromIterable([tsconfigFile]),
63595
64063
  overrides: empty$6(),
63596
- processed: empty()
64064
+ processed: empty(),
64065
+ aliases: []
63597
64066
  }, [tsconfigFile]);
63598
64067
  yield* setOverrides(rt.files, walk.overrides);
63599
64068
  yield* update(rt.state, (prev) => ({
63600
64069
  ...prev,
63601
- allTSConfigFiles: walk.files
64070
+ allTSConfigFiles: walk.files,
64071
+ aliases: walk.aliases
63602
64072
  }));
63603
64073
  const api = new API({ fs: rt.sourceFileSystem });
63604
64074
  const snapshot = yield* promise(() => api.updateSnapshot({ openProjects: Array.from(walk.files) }));
@@ -63607,19 +64077,45 @@ const init = (self) => {
63607
64077
  api,
63608
64078
  snapshot
63609
64079
  }));
63610
- yield* buildGraph(rt, yield* programsOf(rt));
63611
- return yield* check(self, []);
63612
- });
63613
- };
63614
- const diagnosticsOf = (program) => promise(() => Promise.all([
63615
- program.getConfigFileParsingDiagnostics(),
63616
- program.getSemanticDiagnostics(),
63617
- program.getProgramDiagnostics()
63618
- ]).then(([config, semantic, programWide]) => [
63619
- ...config,
63620
- ...semantic,
63621
- ...programWide
63622
- ]));
64080
+ const programs = yield* programsOf(rt);
64081
+ yield* buildGraph(rt, programs);
64082
+ return yield* dryRunDiagnostics(programs);
64083
+ });
64084
+ };
64085
+ const DIAGNOSTIC_BATCH_SIZE = 64;
64086
+ const dependentsSetOf = (dependents, imported) => getOrElse$1(get$4(dependents, imported), () => {
64087
+ const created = empty();
64088
+ set$4(dependents, imported, created);
64089
+ return created;
64090
+ });
64091
+ const recordDependent = (dependents, imported, fileName) => {
64092
+ add(dependentsSetOf(dependents, imported), fileName);
64093
+ };
64094
+ const dependentsOf = (sourceFiles) => {
64095
+ const dependents = empty$6();
64096
+ forEach$3(fromIterable$5(sourceFiles), ([fileName, file]) => forEach$3(fromIterable$5(file.imports), (imported) => recordDependent(dependents, imported, fileName)));
64097
+ return dependents;
64098
+ };
64099
+ const dependentsOfFile = (dependents, fileName) => fromIterable$5(getOrElse$1(get$4(dependents, fileName), empty));
64100
+ const closeOverDependents = (dependents, affected) => {
64101
+ const grown = /* @__PURE__ */ new Set([...affected, ...flatMap$4([...affected], (fileName) => dependentsOfFile(dependents, fileName))]);
64102
+ return match$1(grown.size === affected.size, {
64103
+ onTrue: () => grown,
64104
+ onFalse: () => closeOverDependents(dependents, grown)
64105
+ });
64106
+ };
64107
+ const affectedFileNames = (sourceFiles, mutatedFileNames) => closeOverDependents(dependentsOf(sourceFiles), new Set(mutatedFileNames));
64108
+ const requestedFileNames = (fileNames, presentFileNames) => filter(presentFileNames, (fileName) => fileNames.has(fileName));
64109
+ const diagnosticBatchesOf = (fileNames) => chunksOf(fileNames, DIAGNOSTIC_BATCH_SIZE);
64110
+ const semanticDiagnosticsOf = (program, fileNames) => gen(function* () {
64111
+ const presentFileNames = yield* promise(() => program.getSourceFileNames());
64112
+ return [...yield* forEach$1(diagnosticBatchesOf(requestedFileNames(fileNames, presentFileNames)), (batch) => map$2(promise(() => Promise.all(map$5(batch, (fileName) => program.getSemanticDiagnostics(fileName)))), (perFile) => flatten(perFile)), { concurrency: 1 })].flat();
64113
+ });
64114
+ const programWideDiagnosticsOf = (program) => promise(() => Promise.all([program.getConfigFileParsingDiagnostics(), program.getProgramDiagnostics()]).then(([config, programWide]) => [...config, ...programWide]));
64115
+ const affectedDiagnosticsOf = (program, fileNames) => all([programWideDiagnosticsOf(program), semanticDiagnosticsOf(program, fileNames)], { concurrency: 2 }).pipe(map$2(([programWide, semantic]) => [...semantic, ...programWide]));
64116
+ const wholeProgramDiagnosticsOf = (program) => all([programWideDiagnosticsOf(program), promise(() => program.getSemanticDiagnostics())], { concurrency: 2 }).pipe(map$2(([programWide, semantic]) => [...semantic, ...programWide]));
64117
+ const dryRunDiagnostics = (programs) => map$2(forEach$1(programs, (program) => wholeProgramDiagnosticsOf(program)), (perProgram) => errorDiagnosticsOf(flatten(perProgram))).pipe(withSpan("typescript-checker.compiler.dryRun", { attributes: { "typescript.projects.count": programs.length } }));
64118
+ const errorDiagnosticsOf = (diagnostics) => filter(diagnostics, (diagnostic) => diagnostic.category === DiagnosticCategory.Error);
63623
64119
  const check = dual(2, (self, mutants) => {
63624
64120
  const rt = runtimeOf(self);
63625
64121
  return gen(function* () {
@@ -63634,9 +64130,13 @@ const check = dual(2, (self, mutants) => {
63634
64130
  lastMutants: [...mutants],
63635
64131
  lastMutatedFileNames: mutatedFileNames
63636
64132
  }));
64133
+ const affected = affectedFileNames(state.sourceFiles, mutatedFileNames);
63637
64134
  const programs = yield* programsOf(rt);
63638
- const diagnostics = filter(flatten(yield* forEach$1(programs, (program) => diagnosticsOf(program))), (diagnostic) => diagnostic.category === DiagnosticCategory.Error);
63639
- yield* annotateCurrentSpan({ "typescript.diagnostics.count": diagnostics.length });
64135
+ const diagnostics = errorDiagnosticsOf(flatten(yield* forEach$1(programs, (program) => affectedDiagnosticsOf(program, affected))));
64136
+ yield* annotateCurrentSpan({
64137
+ "typescript.diagnostics.count": diagnostics.length,
64138
+ "typescript.files.count": affected.size
64139
+ });
63640
64140
  yield* annotateDiagnosticSample(diagnostics);
63641
64141
  return diagnostics;
63642
64142
  }).pipe(withSpan("typescript-checker.compiler.check", { attributes: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@systemfsoftware/stryker-js-typescript-checker",
3
- "version": "7.1.1",
3
+ "version": "7.1.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/systemfsoftware/stryker-js-effect.git",
@@ -31,8 +31,8 @@
31
31
  "effect": "4.0.0-rc.117",
32
32
  "typescript": "^7",
33
33
  "@systemfsoftware/stryker-js-instrumenter": "^9.0.1",
34
- "@systemfsoftware/stryker-js-plugin-interface": "^8.0.0",
35
- "@systemfsoftware/stryker-js-plugin-runtime": "^6.0.1"
34
+ "@systemfsoftware/stryker-js-plugin-runtime": "^6.0.2",
35
+ "@systemfsoftware/stryker-js-plugin-interface": "^9.0.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@effect/platform-node": "4.0.0-rc.117",
@@ -58,9 +58,9 @@
58
58
  "rimraf": "^6.1.3",
59
59
  "tsdown": "^0.23.0",
60
60
  "vitest": "^5",
61
+ "@systemfsoftware/tsdown-config": "^0.1.0",
61
62
  "@systemfsoftware/stryker-config": "^0.1.0",
62
- "@systemfsoftware/vitest-config": "^0.1.0",
63
- "@systemfsoftware/tsdown-config": "^0.1.0"
63
+ "@systemfsoftware/vitest-config": "^0.1.0"
64
64
  },
65
65
  "inlinedDependencies": {
66
66
  "@effect/opentelemetry": "4.0.0-rc.117",