tstyche 1.1.0 → 2.0.0-beta.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.
package/README.md CHANGED
@@ -25,7 +25,7 @@ function firstItem<T>(target: Array<T>): T | undefined {
25
25
  }
26
26
 
27
27
  test("firstItem", () => {
28
- expect(firstItem(["a", "b", "c"])).type.toEqual<string | undefined>();
28
+ expect(firstItem(["a", "b", "c"])).type.toBe<string | undefined>();
29
29
 
30
30
  expect(firstItem()).type.toRaiseError("Expected 1 argument");
31
31
  });
@@ -52,13 +52,13 @@ function secondItem<T>(target: Array<T>): T | undefined {
52
52
  test("handles numbers", () => {
53
53
  assert.strictEqual(secondItem([1, 2, 3]), 2);
54
54
 
55
- tstyche.expect(secondItem([1, 2, 3])).type.toEqual<number | undefined>();
55
+ tstyche.expect(secondItem([1, 2, 3])).type.toBe<number | undefined>();
56
56
  });
57
57
  ```
58
58
 
59
59
  Here is the list of all matchers:
60
60
 
61
- - `.toBeAssignable()`, `.toEqual()`, `.toMatch()` compares types or types of expression,
61
+ - `.toBe()`, `.toBeAssignableTo()`, `.toBeAssignableWith()`, `.toMatch()` compare types or types of expression,
62
62
  - `.toHaveProperty()` looks up keys on an object type,
63
63
  - `.toRaiseError()` captures the type error message or code,
64
64
  - `.toBeString()`, `.toBeNumber()`, `.toBeVoid()` and 9 more shorthand checks for primitive types.
@@ -91,8 +91,8 @@ If you have any questions or suggestions, [start a discussion](https://github.co
91
91
  [license-url]: https://github.com/tstyche/tstyche/blob/main/LICENSE.md
92
92
  [requirements-badge]: https://badgen.net/npm/node/tstyche
93
93
  [requirements-url]: https://tstyche.org/reference/requirements
94
- [install-size-badge]: https://badgen.net/install-size/install/tstyche
95
- [install-size-url]: https://install-size.com/result?p=tstyche
94
+ [install-size-badge]: https://badgen.net/packagephobia/install/tstyche
95
+ [install-size-url]: https://packagephobia.com/result?p=tstyche
96
96
  [coverage-badge]: https://badgen.net/codacy/coverage/a581ca5c323a455886b7bdd9623c4ec8
97
97
  [coverage-url]: https://app.codacy.com/gh/tstyche/tstyche/coverage/dashboard
98
98
  [discord-badge]: https://badgen.net/static/chat/on%20Discord
package/build/index.d.cts CHANGED
@@ -60,22 +60,115 @@ interface Test {
60
60
  }
61
61
  interface Matchers {
62
62
  /**
63
- * Checks if the `any` type is identical to the source type.
63
+ * Checks if the source type is identical to the target type.
64
64
  */
65
- toBeAny: () => void;
65
+ toBe: {
66
+ /**
67
+ * Checks if the source type is identical to the target type.
68
+ */
69
+ <Target>(): void;
70
+ /**
71
+ * Checks if the source type is identical to type of the target expression.
72
+ */
73
+ (target: unknown): void;
74
+ };
66
75
  /**
67
- * Checks if the target type is assignable to the source type.
76
+ * Checks if the source type is assignable with the target type.
77
+ *
78
+ * @deprecated Use `.toBeAssignableWith()` or `.toBeAssignableTo()` instead. This matcher will be removed in TSTyche 3.
79
+ * To learn more, visit https://tstyche.org/release-notes/tstyche-2.
68
80
  */
69
81
  toBeAssignable: {
70
82
  /**
71
- * Checks if the target type is assignable to the source type.
83
+ * Checks if the source type is assignable with the target type.
84
+ *
85
+ * @deprecated Use `.toBeAssignableWith()` or `.toBeAssignableTo()` instead. This matcher will be removed in TSTyche 3.
86
+ * To learn more, visit https://tstyche.org/release-notes/tstyche-2.
87
+ */
88
+ <Target>(): void;
89
+ /**
90
+ * Checks if the source type is assignable with type of the target expression.
91
+ *
92
+ * @deprecated Use `.toBeAssignableWith()` or `.toBeAssignableTo()` instead. This matcher will be removed in TSTyche 3.
93
+ * To learn more, visit https://tstyche.org/release-notes/tstyche-2.
94
+ */
95
+ (target: unknown): void;
96
+ };
97
+ /**
98
+ * Checks if the source type is assignable to the target type.
99
+ */
100
+ toBeAssignableTo: {
101
+ /**
102
+ * Checks if the source type is assignable to the target type.
72
103
  */
73
104
  <Target>(): void;
74
105
  /**
75
- * Checks if type of the target expression is assignable to the source type.
106
+ * Checks if the source type is assignable to type of the target expression.
76
107
  */
77
108
  (target: unknown): void;
78
109
  };
110
+ /**
111
+ * Checks if the source type is assignable with the target type.
112
+ */
113
+ toBeAssignableWith: {
114
+ /**
115
+ * Checks if the source type is assignable with the target type.
116
+ */
117
+ <Target>(): void;
118
+ /**
119
+ * Checks if the source type is assignable with type of the target expression.
120
+ */
121
+ (target: unknown): void;
122
+ };
123
+ /**
124
+ * Checks if the source type is identical to the target type.
125
+ *
126
+ * @deprecated Use `.toBe()` instead. This matcher will be removed in TSTyche 3.
127
+ * To learn more, visit https://tstyche.org/release-notes/tstyche-2.
128
+ */
129
+ toEqual: {
130
+ /**
131
+ * Checks if the source type is identical to the target type.
132
+ *
133
+ * @deprecated Use `.toBe()` instead. This matcher will be removed in TSTyche 3.
134
+ * To learn more, visit https://tstyche.org/release-notes/tstyche-2.
135
+ */
136
+ <Target>(): void;
137
+ /**
138
+ * Checks if the source type is identical to type of the target expression.
139
+ *
140
+ * @deprecated This matcher will be removed in TSTyche 3.
141
+ * To learn more, visit https://tstyche.org/release-notes/tstyche-2.
142
+ */
143
+ (target: unknown): void;
144
+ };
145
+ /**
146
+ * Checks if a property key exists on the source type.
147
+ */
148
+ toHaveProperty: (key: string | number | symbol) => void;
149
+ /**
150
+ * Checks if the source type matches the target type.
151
+ */
152
+ toMatch: {
153
+ /**
154
+ * Checks if the source type matches the target type.
155
+ */
156
+ <Target>(): void;
157
+ /**
158
+ * Checks if the source type matches type of the target expression.
159
+ */
160
+ (target: unknown): void;
161
+ };
162
+ /**
163
+ * Checks if the source type raises an error.
164
+ */
165
+ toRaiseError: (...target: Array<string | number>) => void;
166
+ }
167
+ interface Matchers {
168
+ /**
169
+ * Checks if the source type is `any`.
170
+ */
171
+ toBeAny: () => void;
79
172
  /**
80
173
  * Checks if the source type is `bigint`.
81
174
  */
@@ -120,40 +213,6 @@ interface Matchers {
120
213
  * Checks if the source type is `void`.
121
214
  */
122
215
  toBeVoid: () => void;
123
- /**
124
- * Check if the target type is identical to the source type.
125
- */
126
- toEqual: {
127
- /**
128
- * Checks if the target type is identical to the source type.
129
- */
130
- <Target>(): void;
131
- /**
132
- * Checks if type of the target expression is identical to the source type.
133
- */
134
- (target: unknown): void;
135
- };
136
- /**
137
- * Checks if a property key exists on the source type.
138
- */
139
- toHaveProperty: (key: string | number | symbol) => void;
140
- /**
141
- * Checks if the target type is a subtype the source type.
142
- */
143
- toMatch: {
144
- /**
145
- * Checks if the target type is a subtype the source type.
146
- */
147
- <Target>(): void;
148
- /**
149
- * Checks if type of the target expression is a subtype the source type.
150
- */
151
- (target: unknown): void;
152
- };
153
- /**
154
- * Checks if the source type raises an error.
155
- */
156
- toRaiseError: (...target: Array<string | number>) => void;
157
216
  }
158
217
  interface Modifier {
159
218
  /**
package/build/index.d.ts CHANGED
@@ -60,22 +60,115 @@ interface Test {
60
60
  }
61
61
  interface Matchers {
62
62
  /**
63
- * Checks if the `any` type is identical to the source type.
63
+ * Checks if the source type is identical to the target type.
64
64
  */
65
- toBeAny: () => void;
65
+ toBe: {
66
+ /**
67
+ * Checks if the source type is identical to the target type.
68
+ */
69
+ <Target>(): void;
70
+ /**
71
+ * Checks if the source type is identical to type of the target expression.
72
+ */
73
+ (target: unknown): void;
74
+ };
66
75
  /**
67
- * Checks if the target type is assignable to the source type.
76
+ * Checks if the source type is assignable with the target type.
77
+ *
78
+ * @deprecated Use `.toBeAssignableWith()` or `.toBeAssignableTo()` instead. This matcher will be removed in TSTyche 3.
79
+ * To learn more, visit https://tstyche.org/release-notes/tstyche-2.
68
80
  */
69
81
  toBeAssignable: {
70
82
  /**
71
- * Checks if the target type is assignable to the source type.
83
+ * Checks if the source type is assignable with the target type.
84
+ *
85
+ * @deprecated Use `.toBeAssignableWith()` or `.toBeAssignableTo()` instead. This matcher will be removed in TSTyche 3.
86
+ * To learn more, visit https://tstyche.org/release-notes/tstyche-2.
87
+ */
88
+ <Target>(): void;
89
+ /**
90
+ * Checks if the source type is assignable with type of the target expression.
91
+ *
92
+ * @deprecated Use `.toBeAssignableWith()` or `.toBeAssignableTo()` instead. This matcher will be removed in TSTyche 3.
93
+ * To learn more, visit https://tstyche.org/release-notes/tstyche-2.
94
+ */
95
+ (target: unknown): void;
96
+ };
97
+ /**
98
+ * Checks if the source type is assignable to the target type.
99
+ */
100
+ toBeAssignableTo: {
101
+ /**
102
+ * Checks if the source type is assignable to the target type.
72
103
  */
73
104
  <Target>(): void;
74
105
  /**
75
- * Checks if type of the target expression is assignable to the source type.
106
+ * Checks if the source type is assignable to type of the target expression.
76
107
  */
77
108
  (target: unknown): void;
78
109
  };
110
+ /**
111
+ * Checks if the source type is assignable with the target type.
112
+ */
113
+ toBeAssignableWith: {
114
+ /**
115
+ * Checks if the source type is assignable with the target type.
116
+ */
117
+ <Target>(): void;
118
+ /**
119
+ * Checks if the source type is assignable with type of the target expression.
120
+ */
121
+ (target: unknown): void;
122
+ };
123
+ /**
124
+ * Checks if the source type is identical to the target type.
125
+ *
126
+ * @deprecated Use `.toBe()` instead. This matcher will be removed in TSTyche 3.
127
+ * To learn more, visit https://tstyche.org/release-notes/tstyche-2.
128
+ */
129
+ toEqual: {
130
+ /**
131
+ * Checks if the source type is identical to the target type.
132
+ *
133
+ * @deprecated Use `.toBe()` instead. This matcher will be removed in TSTyche 3.
134
+ * To learn more, visit https://tstyche.org/release-notes/tstyche-2.
135
+ */
136
+ <Target>(): void;
137
+ /**
138
+ * Checks if the source type is identical to type of the target expression.
139
+ *
140
+ * @deprecated This matcher will be removed in TSTyche 3.
141
+ * To learn more, visit https://tstyche.org/release-notes/tstyche-2.
142
+ */
143
+ (target: unknown): void;
144
+ };
145
+ /**
146
+ * Checks if a property key exists on the source type.
147
+ */
148
+ toHaveProperty: (key: string | number | symbol) => void;
149
+ /**
150
+ * Checks if the source type matches the target type.
151
+ */
152
+ toMatch: {
153
+ /**
154
+ * Checks if the source type matches the target type.
155
+ */
156
+ <Target>(): void;
157
+ /**
158
+ * Checks if the source type matches type of the target expression.
159
+ */
160
+ (target: unknown): void;
161
+ };
162
+ /**
163
+ * Checks if the source type raises an error.
164
+ */
165
+ toRaiseError: (...target: Array<string | number>) => void;
166
+ }
167
+ interface Matchers {
168
+ /**
169
+ * Checks if the source type is `any`.
170
+ */
171
+ toBeAny: () => void;
79
172
  /**
80
173
  * Checks if the source type is `bigint`.
81
174
  */
@@ -120,40 +213,6 @@ interface Matchers {
120
213
  * Checks if the source type is `void`.
121
214
  */
122
215
  toBeVoid: () => void;
123
- /**
124
- * Check if the target type is identical to the source type.
125
- */
126
- toEqual: {
127
- /**
128
- * Checks if the target type is identical to the source type.
129
- */
130
- <Target>(): void;
131
- /**
132
- * Checks if type of the target expression is identical to the source type.
133
- */
134
- (target: unknown): void;
135
- };
136
- /**
137
- * Checks if a property key exists on the source type.
138
- */
139
- toHaveProperty: (key: string | number | symbol) => void;
140
- /**
141
- * Checks if the target type is a subtype the source type.
142
- */
143
- toMatch: {
144
- /**
145
- * Checks if the target type is a subtype the source type.
146
- */
147
- <Target>(): void;
148
- /**
149
- * Checks if type of the target expression is a subtype the source type.
150
- */
151
- (target: unknown): void;
152
- };
153
- /**
154
- * Checks if the source type raises an error.
155
- */
156
- toRaiseError: (...target: Array<string | number>) => void;
157
216
  }
158
217
  interface Modifier {
159
218
  /**