tstyche 4.0.0-beta.9 → 4.0.0-rc.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/README.md CHANGED
@@ -77,7 +77,7 @@ This simple! (And it has watch mode too.)
77
77
 
78
78
  ## Documentation
79
79
 
80
- Visit [https://tstyche.org](https://tstyche.org) to view the full documentation.
80
+ Visit [tstyche.org](https://tstyche.org) to view the full documentation.
81
81
 
82
82
  ## Feedback
83
83
 
package/build/index.d.cts CHANGED
@@ -85,15 +85,15 @@ interface Matchers {
85
85
  (target: unknown): void;
86
86
  };
87
87
  /**
88
- * Checks if the source type is identical to the target type.
88
+ * Checks if the source type is the same as the target type.
89
89
  */
90
90
  toBe: {
91
91
  /**
92
- * Checks if the source type is identical to the target type.
92
+ * Checks if the source type is the same as the target type.
93
93
  */
94
94
  <Target>(): void;
95
95
  /**
96
- * Checks if the source type is identical to type of the target expression.
96
+ * Checks if the source type is the same as type of the target expression.
97
97
  */
98
98
  (target: unknown): void;
99
99
  };
package/build/index.d.ts CHANGED
@@ -85,15 +85,15 @@ interface Matchers {
85
85
  (target: unknown): void;
86
86
  };
87
87
  /**
88
- * Checks if the source type is identical to the target type.
88
+ * Checks if the source type is the same as the target type.
89
89
  */
90
90
  toBe: {
91
91
  /**
92
- * Checks if the source type is identical to the target type.
92
+ * Checks if the source type is the same as the target type.
93
93
  */
94
94
  <Target>(): void;
95
95
  /**
96
- * Checks if the source type is identical to type of the target expression.
96
+ * Checks if the source type is the same as type of the target expression.
97
97
  */
98
98
  (target: unknown): void;
99
99
  };
@@ -610,14 +610,9 @@ interface MatchResult {
610
610
  explain: () => Array<Diagnostic>;
611
611
  isMatch: boolean;
612
612
  }
613
- type Relation = Map<string, unknown>;
614
613
  interface TypeChecker extends ts.TypeChecker {
615
614
  isApplicableIndexType: (source: ts.Type, target: ts.Type) => boolean;
616
- isTypeRelatedTo: (source: ts.Type, target: ts.Type, relation: Relation) => boolean;
617
- relation: {
618
- assignable: Relation;
619
- identity: Relation;
620
- };
615
+ isTypeIdenticalTo: (source: ts.Type, target: ts.Type) => boolean;
621
616
  }
622
617
 
623
618
  declare class ExpectService {
package/build/tstyche.js CHANGED
@@ -810,11 +810,7 @@ class Store {
810
810
  modulePath = Path.resolve(modulePath, "../tsserverlibrary.js");
811
811
  }
812
812
  const sourceText = await fs.readFile(modulePath, { encoding: "utf8" });
813
- const toExpose = [
814
- "isApplicableIndexType",
815
- "isTypeRelatedTo",
816
- "relation: { assignable: assignableRelation, identity: identityRelation }",
817
- ];
813
+ const toExpose = ["isApplicableIndexType", "isTypeIdenticalTo"];
818
814
  const modifiedSourceText = sourceText.replace("return checker;", `return { ...checker, ${toExpose.join(", ")} };`);
819
815
  const compiledWrapper = vm.compileFunction(modifiedSourceText, ["exports", "require", "module", "__filename", "__dirname"], { filename: modulePath });
820
816
  compiledWrapper(exports, createRequire(modulePath), module, modulePath, Path.dirname(modulePath));
@@ -2930,10 +2926,10 @@ class AssertionNode extends TestTreeNode {
2930
2926
  }
2931
2927
 
2932
2928
  function nodeBelongsToArgumentList(compiler, node) {
2933
- if (compiler.isCallExpression(node.parent)) {
2934
- return node.parent.arguments.some((argument) => argument === node);
2935
- }
2936
- return false;
2929
+ return compiler.isCallExpression(node.parent) && node.parent.arguments.some((argument) => argument === node);
2930
+ }
2931
+ function nodeIsChildOfExpressionStatement(compiler, node) {
2932
+ return compiler.isExpressionStatement(node.parent);
2937
2933
  }
2938
2934
 
2939
2935
  class AbilityLayer {
@@ -3013,7 +3009,7 @@ class AbilityLayer {
3013
3009
  {
3014
3010
  start: whenStart,
3015
3011
  end: whenExpressionEnd,
3016
- replacement: nodeBelongsToArgumentList(this.#compiler, whenNode.actionNode) ? "" : ";",
3012
+ replacement: nodeIsChildOfExpressionStatement(this.#compiler, whenNode.actionNode) ? ";" : "",
3017
3013
  },
3018
3014
  { start: whenEnd, end: actionNameEnd },
3019
3015
  ]);
@@ -3038,7 +3034,7 @@ class AbilityLayer {
3038
3034
  {
3039
3035
  start: expectStart,
3040
3036
  end: expectExpressionEnd,
3041
- replacement: nodeBelongsToArgumentList(this.#compiler, assertionNode.matcherNode) ? "" : ";",
3037
+ replacement: nodeIsChildOfExpressionStatement(this.#compiler, assertionNode.matcherNode) ? ";" : "",
3042
3038
  },
3043
3039
  { start: expectEnd, end: matcherNameEnd },
3044
3040
  ]);
@@ -3049,7 +3045,7 @@ class AbilityLayer {
3049
3045
  {
3050
3046
  start: expectStart,
3051
3047
  end: expectExpressionEnd,
3052
- replacement: nodeBelongsToArgumentList(this.#compiler, assertionNode.matcherNode) ? "new" : "; new",
3048
+ replacement: nodeIsChildOfExpressionStatement(this.#compiler, assertionNode.matcherNode) ? "; new" : "new",
3053
3049
  },
3054
3050
  { start: expectEnd, end: matcherNameEnd },
3055
3051
  ]);
@@ -3618,11 +3614,11 @@ class ExpectDiagnosticText {
3618
3614
  static isNotAssignableWith(sourceTypeText, targetTypeText) {
3619
3615
  return `Type '${sourceTypeText}' is not assignable with type '${targetTypeText}'.`;
3620
3616
  }
3621
- static isIdenticalTo(sourceTypeText, targetTypeText) {
3622
- return `Type '${sourceTypeText}' is identical to type '${targetTypeText}'.`;
3617
+ static isTheSame(sourceTypeText, targetTypeText) {
3618
+ return `Type '${sourceTypeText}' is the same as type '${targetTypeText}'.`;
3623
3619
  }
3624
- static isNotIdenticalTo(sourceTypeText, targetTypeText) {
3625
- return `Type '${sourceTypeText}' is not identical to type '${targetTypeText}'.`;
3620
+ static isNotTheSame(sourceTypeText, targetTypeText) {
3621
+ return `Type '${sourceTypeText}' is not the same as type '${targetTypeText}'.`;
3626
3622
  }
3627
3623
  static isNotCompatibleWith(sourceTypeText, targetTypeText) {
3628
3624
  return `Type '${sourceTypeText}' is not compatible with type '${targetTypeText}'.`;
@@ -3635,6 +3631,12 @@ class ExpectDiagnosticText {
3635
3631
  }
3636
3632
  }
3637
3633
 
3634
+ var Relation;
3635
+ (function (Relation) {
3636
+ Relation["Assignable"] = "assignable";
3637
+ Relation["Identical"] = "identical";
3638
+ })(Relation || (Relation = {}));
3639
+
3638
3640
  class MatchWorker {
3639
3641
  assertion;
3640
3642
  #compiler;
@@ -3659,27 +3661,25 @@ class MatchWorker {
3659
3661
  .some((property) => this.#compiler.unescapeLeadingUnderscores(property.escapedName) === propertyNameText);
3660
3662
  }
3661
3663
  checkIsAssignableTo(sourceNode, targetNode) {
3662
- const relation = this.typeChecker.relation.assignable;
3663
- return this.#checkIsRelatedTo(sourceNode, targetNode, relation);
3664
+ return this.#checkIsRelatedTo(sourceNode, targetNode, Relation.Assignable);
3664
3665
  }
3665
3666
  checkIsAssignableWith(sourceNode, targetNode) {
3666
- const relation = this.typeChecker.relation.assignable;
3667
- return this.#checkIsRelatedTo(targetNode, sourceNode, relation);
3667
+ return this.#checkIsRelatedTo(targetNode, sourceNode, Relation.Assignable);
3668
3668
  }
3669
3669
  checkIsIdenticalTo(sourceNode, targetNode) {
3670
- const relation = this.typeChecker.relation.identity;
3671
- return (this.#checkIsRelatedTo(sourceNode, targetNode, relation) &&
3670
+ return (this.#checkIsRelatedTo(sourceNode, targetNode, Relation.Identical) &&
3672
3671
  this.checkIsAssignableTo(sourceNode, targetNode) &&
3673
3672
  this.checkIsAssignableWith(sourceNode, targetNode));
3674
3673
  }
3675
3674
  #checkIsRelatedTo(sourceNode, targetNode, relation) {
3676
- const sourceType = relation === this.typeChecker.relation.identity
3677
- ? this.#simplifyType(this.getType(sourceNode))
3678
- : this.getType(sourceNode);
3679
- const targetType = relation === this.typeChecker.relation.identity
3680
- ? this.#simplifyType(this.getType(targetNode))
3681
- : this.getType(targetNode);
3682
- return this.typeChecker.isTypeRelatedTo(sourceType, targetType, relation);
3675
+ const sourceType = relation === "identical" ? this.#simplifyType(this.getType(sourceNode)) : this.getType(sourceNode);
3676
+ const targetType = relation === "identical" ? this.#simplifyType(this.getType(targetNode)) : this.getType(targetNode);
3677
+ switch (relation) {
3678
+ case Relation.Assignable:
3679
+ return this.typeChecker.isTypeAssignableTo(sourceType, targetType);
3680
+ case Relation.Identical:
3681
+ return this.typeChecker.isTypeIdenticalTo(sourceType, targetType);
3682
+ }
3683
3683
  }
3684
3684
  extendsObjectType(type) {
3685
3685
  const nonPrimitiveType = { flags: this.#compiler.TypeFlags.NonPrimitive };
@@ -3723,7 +3723,7 @@ class MatchWorker {
3723
3723
  #simplifyType(type) {
3724
3724
  if (type.isUnionOrIntersection()) {
3725
3725
  const candidateType = this.#simplifyType(type.types[0]);
3726
- if (type.types.every((type) => this.typeChecker.isTypeRelatedTo(this.#simplifyType(type), candidateType, this.typeChecker.relation.identity))) {
3726
+ if (type.types.every((type) => this.typeChecker.isTypeIdenticalTo(this.#simplifyType(type), candidateType))) {
3727
3727
  return candidateType;
3728
3728
  }
3729
3729
  }
@@ -3938,8 +3938,8 @@ class RelationMatcherBase {
3938
3938
  }
3939
3939
 
3940
3940
  class ToBe extends RelationMatcherBase {
3941
- explainText = ExpectDiagnosticText.isIdenticalTo;
3942
- explainNotText = ExpectDiagnosticText.isNotIdenticalTo;
3941
+ explainText = ExpectDiagnosticText.isTheSame;
3942
+ explainNotText = ExpectDiagnosticText.isNotTheSame;
3943
3943
  match(matchWorker, sourceNode, targetNode) {
3944
3944
  return {
3945
3945
  explain: () => this.explain(matchWorker, sourceNode, targetNode),
@@ -4762,7 +4762,7 @@ class TaskRunner {
4762
4762
  class Runner {
4763
4763
  #eventEmitter = new EventEmitter();
4764
4764
  #resolvedConfig;
4765
- static version = "4.0.0-beta.9";
4765
+ static version = "4.0.0-rc.0";
4766
4766
  constructor(resolvedConfig) {
4767
4767
  this.#resolvedConfig = resolvedConfig;
4768
4768
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tstyche",
3
- "version": "4.0.0-beta.9",
3
+ "version": "4.0.0-rc.0",
4
4
  "description": "The Essential Type Testing Tool.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -31,50 +31,6 @@
31
31
  "main": "./build/index.js",
32
32
  "types": "./build/index.d.ts",
33
33
  "bin": "./build/bin.js",
34
- "files": [
35
- "build/*"
36
- ],
37
- "scripts": {
38
- "bench": "./benchmarks/tstyche.bench.sh",
39
- "build": "rollup --config rollup.config.js",
40
- "build:watch": "yarn build --sourcemap --watch",
41
- "check": "yarn check:spelling && yarn check:types",
42
- "check:spelling": "cspell --config cspell.config.json --quiet",
43
- "check:types": "tsc --noEmit --project tsconfig.json",
44
- "format": "biome format --write",
45
- "generate": "yarn generate:schema && yarn generate:types",
46
- "generate:schema": "node ./scripts/generate-schema.js",
47
- "generate:types": "node ./scripts/generate-types.js",
48
- "lint": "biome lint --write",
49
- "prepublish": "yarn build",
50
- "test": "yarn test:unit && yarn test:e2e",
51
- "test:coverage": "yarn test:coverage:collect && yarn test:coverage:report",
52
- "test:coverage:collect": "yarn build --sourcemap && NODE_V8_COVERAGE='./coverage/v8-coverage' yarn test:e2e",
53
- "test:coverage:report": "node ./scripts/report-coverage.js",
54
- "test:e2e": "yarn test:e2e:parallel && yarn test:e2e:serial",
55
- "test:e2e:parallel": "yarn test:run tests/*.test.js --exclude feature --parallel",
56
- "test:e2e:serial": "yarn test:run tests/*.test.js --include feature",
57
- "test:examples": "NODE_OPTIONS='--import ts-blank-space/register' tstyche examples",
58
- "test:run": "rm -rf ./tests/__fixtures__/.generated && yarn node ./tests/__utilities__/runner.js",
59
- "test:types": "tstyche typetests",
60
- "test:unit": "yarn test:run **/__tests__/*.test.js --parallel"
61
- },
62
- "devDependencies": {
63
- "@biomejs/biome": "1.9.4",
64
- "@rollup/plugin-typescript": "12.1.2",
65
- "@types/node": "22.15.15",
66
- "@types/react": "19.1.3",
67
- "ajv": "8.17.1",
68
- "cspell": "9.0.0",
69
- "magic-string": "0.30.17",
70
- "monocart-coverage-reports": "2.12.4",
71
- "pretty-ansi": "3.0.0",
72
- "rollup": "4.40.2",
73
- "rollup-plugin-dts": "6.2.1",
74
- "ts-blank-space": "0.6.1",
75
- "tslib": "2.8.1",
76
- "typescript": "5.8.3"
77
- },
78
34
  "peerDependencies": {
79
35
  "typescript": ">=4.7"
80
36
  },
@@ -83,7 +39,6 @@
83
39
  "optional": true
84
40
  }
85
41
  },
86
- "packageManager": "yarn@4.9.1",
87
42
  "engines": {
88
43
  "node": ">=20.9"
89
44
  }