@deessejs/type-testing 0.1.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/.eslintrc.json +7 -0
- package/.turbo/turbo-lint.log +24 -0
- package/.turbo/turbo-test.log +23 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/CHANGELOG.md +7 -0
- package/README.md +303 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/coverage-final.json +15 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +146 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/coverage/src/api/assert.ts.html +229 -0
- package/coverage/src/api/check.ts.html +586 -0
- package/coverage/src/api/expect.ts.html +220 -0
- package/coverage/src/api/index.html +161 -0
- package/coverage/src/api/index.ts.html +106 -0
- package/coverage/src/index.html +131 -0
- package/coverage/src/index.ts.html +127 -0
- package/coverage/src/types/equality.ts.html +190 -0
- package/coverage/src/types/function.ts.html +139 -0
- package/coverage/src/types/index.html +221 -0
- package/coverage/src/types/index.ts.html +121 -0
- package/coverage/src/types/inhabitation.ts.html +160 -0
- package/coverage/src/types/length.ts.html +109 -0
- package/coverage/src/types/property.ts.html +124 -0
- package/coverage/src/types/special.ts.html +274 -0
- package/coverage/src/types/union.ts.html +193 -0
- package/coverage/src/utils.ts.html +136 -0
- package/dist/api/assert.d.ts +43 -0
- package/dist/api/assert.d.ts.map +1 -0
- package/dist/api/assert.js +7 -0
- package/dist/api/assert.js.map +1 -0
- package/dist/api/check.d.ts +138 -0
- package/dist/api/check.d.ts.map +1 -0
- package/dist/api/check.js +17 -0
- package/dist/api/check.js.map +1 -0
- package/dist/api/expect.d.ts +35 -0
- package/dist/api/expect.d.ts.map +1 -0
- package/dist/api/expect.js +21 -0
- package/dist/api/expect.js.map +1 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +7 -0
- package/dist/api/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/index.test.d.ts +8 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +264 -0
- package/dist/index.test.js.map +1 -0
- package/dist/types/equality.d.ts +30 -0
- package/dist/types/equality.d.ts.map +1 -0
- package/dist/types/equality.js +5 -0
- package/dist/types/equality.js.map +1 -0
- package/dist/types/function.d.ts +16 -0
- package/dist/types/function.d.ts.map +1 -0
- package/dist/types/function.js +5 -0
- package/dist/types/function.js.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/inhabitation.d.ts +24 -0
- package/dist/types/inhabitation.d.ts.map +1 -0
- package/dist/types/inhabitation.js +5 -0
- package/dist/types/inhabitation.js.map +1 -0
- package/dist/types/length.d.ts +8 -0
- package/dist/types/length.d.ts.map +1 -0
- package/dist/types/length.js +5 -0
- package/dist/types/length.js.map +1 -0
- package/dist/types/property.d.ts +12 -0
- package/dist/types/property.d.ts.map +1 -0
- package/dist/types/property.js +5 -0
- package/dist/types/property.js.map +1 -0
- package/dist/types/special.d.ts +55 -0
- package/dist/types/special.d.ts.map +1 -0
- package/dist/types/special.js +5 -0
- package/dist/types/special.js.map +1 -0
- package/dist/types/union.d.ts +34 -0
- package/dist/types/union.d.ts.map +1 -0
- package/dist/types/union.js +5 -0
- package/dist/types/union.js.map +1 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +5 -0
- package/dist/utils.js.map +1 -0
- package/package.json +27 -0
- package/public/icon.png +0 -0
- package/src/api/assert.ts +48 -0
- package/src/api/check.ts +167 -0
- package/src/api/expect.ts +45 -0
- package/src/api/index.ts +7 -0
- package/src/index.ts +14 -0
- package/src/types/equality.ts +35 -0
- package/src/types/function.ts +18 -0
- package/src/types/index.ts +12 -0
- package/src/types/inhabitation.ts +25 -0
- package/src/types/length.ts +8 -0
- package/src/types/property.ts +13 -0
- package/src/types/special.ts +63 -0
- package/src/types/union.ts +36 -0
- package/src/utils.ts +17 -0
- package/tests/api.test.ts +40 -0
- package/tests/equality.test.ts +57 -0
- package/tests/function.test.ts +32 -0
- package/tests/inhabitation.test.ts +40 -0
- package/tests/length.test.ts +18 -0
- package/tests/property.test.ts +35 -0
- package/tests/special.test.ts +132 -0
- package/tests/union.test.ts +58 -0
- package/tests/utils.test.ts +20 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
> @deessejs/type-testing@0.1.0 lint C:\Users\dpereira\Documents\github\type-testing\packages\type-testing
|
|
3
|
+
> eslint src --ext .ts,.tsx
|
|
4
|
+
|
|
5
|
+
(node:10876) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///C:/Users/dpereira/Documents/github/type-testing/eslint.config.js?mtime=1772199688344 is not specified and it doesn't parse as CommonJS.
|
|
6
|
+
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
|
|
7
|
+
To eliminate this warning, add "type": "module" to C:\Users\dpereira\Documents\github\type-testing\package.json.
|
|
8
|
+
(Use `node --trace-warnings ...` to show where the warning was created)
|
|
9
|
+
|
|
10
|
+
C:\Users\dpereira\Documents\github\type-testing\packages\type-testing\src\api\assert.ts
|
|
11
|
+
43:1 warning Unused eslint-disable directive (no problems were reported from '@typescript-eslint/no-unused-vars')
|
|
12
|
+
|
|
13
|
+
C:\Users\dpereira\Documents\github\type-testing\packages\type-testing\src\api\check.ts
|
|
14
|
+
21:1 warning Unused eslint-disable directive (no problems were reported from '@typescript-eslint/no-unused-vars')
|
|
15
|
+
|
|
16
|
+
C:\Users\dpereira\Documents\github\type-testing\packages\type-testing\src\api\expect.ts
|
|
17
|
+
25:1 warning Unused eslint-disable directive (no problems were reported from '@typescript-eslint/no-unused-vars')
|
|
18
|
+
|
|
19
|
+
C:\Users\dpereira\Documents\github\type-testing\packages\type-testing\src\utils.ts
|
|
20
|
+
11:1 warning Unused eslint-disable directive (no problems were reported from '@typescript-eslint/no-unused-vars')
|
|
21
|
+
|
|
22
|
+
✖ 4 problems (0 errors, 4 warnings)
|
|
23
|
+
0 errors and 4 warnings potentially fixable with the `--fix` option.
|
|
24
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
> @deessejs/type-testing@0.1.0 test C:\Users\dpereira\Documents\github\type-testing\packages\type-testing
|
|
3
|
+
> vitest run
|
|
4
|
+
|
|
5
|
+
[33mThe CJS build of Vite's Node API is deprecated. See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.[39m
|
|
6
|
+
|
|
7
|
+
[1m[7m[36m RUN [39m[27m[22m [36mv2.1.9 [39m[90mC:/Users/dpereira/Documents/github/type-testing/packages/type-testing[39m
|
|
8
|
+
|
|
9
|
+
[32m✓[39m tests/inhabitation.test.ts [2m([22m[2m6 tests[22m[2m)[22m[90m 4[2mms[22m[39m
|
|
10
|
+
[32m✓[39m tests/property.test.ts [2m([22m[2m5 tests[22m[2m)[22m[90m 4[2mms[22m[39m
|
|
11
|
+
[32m✓[39m tests/equality.test.ts [2m([22m[2m9 tests[22m[2m)[22m[90m 5[2mms[22m[39m
|
|
12
|
+
[32m✓[39m tests/special.test.ts [2m([22m[2m22 tests[22m[2m)[22m[90m 7[2mms[22m[39m
|
|
13
|
+
[32m✓[39m tests/function.test.ts [2m([22m[2m4 tests[22m[2m)[22m[90m 4[2mms[22m[39m
|
|
14
|
+
[32m✓[39m tests/union.test.ts [2m([22m[2m9 tests[22m[2m)[22m[90m 5[2mms[22m[39m
|
|
15
|
+
[32m✓[39m tests/length.test.ts [2m([22m[2m2 tests[22m[2m)[22m[90m 3[2mms[22m[39m
|
|
16
|
+
[32m✓[39m tests/utils.test.ts [2m([22m[2m2 tests[22m[2m)[22m[90m 4[2mms[22m[39m
|
|
17
|
+
[32m✓[39m tests/api.test.ts [2m([22m[2m4 tests[22m[2m)[22m[90m 5[2mms[22m[39m
|
|
18
|
+
|
|
19
|
+
[2m Test Files [22m [1m[32m9 passed[39m[22m[90m (9)[39m
|
|
20
|
+
[2m Tests [22m [1m[32m63 passed[39m[22m[90m (63)[39m
|
|
21
|
+
[2m Start at [22m 15:29:08
|
|
22
|
+
[2m Duration [22m 1.15s[2m (transform 557ms, setup 0ms, collect 1.04s, tests 40ms, environment 3ms, prepare 2.60s)[22m
|
|
23
|
+
|
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# @deessejs/type-testing
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
A micro library for compile-time type testing in TypeScript.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@deessejs/type-testing)
|
|
8
|
+
[](https://www.npmjs.com/package/@deessejs/type-testing)
|
|
9
|
+
[](https://www.typescriptlang.org/)
|
|
10
|
+
[](https://opensource.org/licenses/MIT)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @deessejs/type-testing
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Or with pnpm:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pnpm add @deessejs/type-testing
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or with yarn:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
yarn add @deessejs/type-testing
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { Equal, check, assert, expect } from '@deessejs/type-testing'
|
|
34
|
+
|
|
35
|
+
// Simple type equality
|
|
36
|
+
type Test = Equal<string, string> // true
|
|
37
|
+
|
|
38
|
+
// Chainable API
|
|
39
|
+
check<string>().equals<string>() // passes
|
|
40
|
+
|
|
41
|
+
// Assert with clear errors
|
|
42
|
+
assert<{ a: string }>().hasProperty('a')
|
|
43
|
+
|
|
44
|
+
// Expect syntax
|
|
45
|
+
expect<string, string>().toBeEqual()
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Core Types
|
|
49
|
+
|
|
50
|
+
### Type Equality
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { Equal, NotEqual, SimpleEqual } from '@deessejs/type-testing'
|
|
54
|
+
|
|
55
|
+
// Strict equality (handles any, never, etc.)
|
|
56
|
+
Equal<string, string> // true
|
|
57
|
+
Equal<string, number> // false
|
|
58
|
+
|
|
59
|
+
// Inequality check
|
|
60
|
+
NotEqual<string, number> // true
|
|
61
|
+
|
|
62
|
+
// Simple equality (for plain objects)
|
|
63
|
+
SimpleEqual<{ a: string }, { a: string }> // true
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Special Type Detection
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import {
|
|
70
|
+
IsAny,
|
|
71
|
+
IsNever,
|
|
72
|
+
IsUnknown,
|
|
73
|
+
IsVoid,
|
|
74
|
+
IsUndefined,
|
|
75
|
+
IsNull,
|
|
76
|
+
IsNullable,
|
|
77
|
+
IsOptional
|
|
78
|
+
} from '@deessejs/type-testing'
|
|
79
|
+
|
|
80
|
+
IsAny<any> // true
|
|
81
|
+
IsNever<never> // true
|
|
82
|
+
IsUnknown<unknown> // true
|
|
83
|
+
IsVoid<void> // true
|
|
84
|
+
IsUndefined<undefined> // true
|
|
85
|
+
IsNull<null> // true
|
|
86
|
+
|
|
87
|
+
// Nullable = null | undefined
|
|
88
|
+
IsNullable<string | null> // true
|
|
89
|
+
IsNullable<string | undefined> // true
|
|
90
|
+
|
|
91
|
+
// Optional = may include undefined
|
|
92
|
+
IsOptional<string | undefined> // true
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Union, Tuple & Array
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { IsUnion, IsTuple, IsArray } from '@deessejs/type-testing'
|
|
99
|
+
|
|
100
|
+
// Unions
|
|
101
|
+
IsUnion<'a' | 'b'> // true
|
|
102
|
+
IsUnion<'a'> // false
|
|
103
|
+
|
|
104
|
+
// Tuples (fixed-length arrays)
|
|
105
|
+
IsTuple<[string, number]> // true
|
|
106
|
+
IsTuple<[]> // true
|
|
107
|
+
IsTuple<string[]> // false
|
|
108
|
+
|
|
109
|
+
// Arrays (dynamic-length)
|
|
110
|
+
IsArray<string[]> // true
|
|
111
|
+
IsArray<[string]> // false
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Type Inhabitation
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { IsInhabited, IsUninhabited } from '@deessejs/type-testing'
|
|
118
|
+
|
|
119
|
+
// Has at least one value
|
|
120
|
+
IsInhabited<string> // true
|
|
121
|
+
IsInhabited<never> // false
|
|
122
|
+
|
|
123
|
+
// Has no values (never)
|
|
124
|
+
IsUninhabited<never> // true
|
|
125
|
+
IsUninhabited<string> // false
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Property Testing
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { HasProperty, PropertyType } from '@deessejs/type-testing'
|
|
132
|
+
|
|
133
|
+
// Check if type has a property
|
|
134
|
+
HasProperty<{ a: string }, 'a'> // true
|
|
135
|
+
HasProperty<{ a: string }, 'b'> // false
|
|
136
|
+
|
|
137
|
+
// Get property type
|
|
138
|
+
PropertyType<{ a: string }, 'a'> // string
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Function Types
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
import { Parameters, ReturnType, Parameter } from '@deessejs/type-testing'
|
|
145
|
+
|
|
146
|
+
// Get parameters as tuple
|
|
147
|
+
Parameters<(a: string, b: number) => void> // [string, number]
|
|
148
|
+
|
|
149
|
+
// Get return type
|
|
150
|
+
ReturnType<(a: string) => number> // number
|
|
151
|
+
|
|
152
|
+
// Get parameter at index
|
|
153
|
+
Parameter<(a: string, b: number), 0> // string
|
|
154
|
+
Parameter<(a: string, b: number), 1> // number
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Length
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { Length } from '@deessejs/type-testing'
|
|
161
|
+
|
|
162
|
+
Length<['a', 'b', 'c']> // 3
|
|
163
|
+
Length<[]> // 0
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Chainable API
|
|
167
|
+
|
|
168
|
+
### check() - Soft type checking
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
import { check } from '@deessejs/type-testing'
|
|
172
|
+
|
|
173
|
+
// Type equality
|
|
174
|
+
check<string>().equals<string>() // passes
|
|
175
|
+
check<string>().equals<number>() // fails at compile time
|
|
176
|
+
|
|
177
|
+
// Type extends
|
|
178
|
+
check<string>().extends<string>() // passes
|
|
179
|
+
check<string>().extends<any>() // passes
|
|
180
|
+
|
|
181
|
+
// Property check
|
|
182
|
+
check<{ a: string }>().hasProperty('a') // passes
|
|
183
|
+
check<{ a: string }>().hasProperty('b') // fails
|
|
184
|
+
|
|
185
|
+
// Special types
|
|
186
|
+
check<any>().isAny() // passes
|
|
187
|
+
check<never>().isNever() // passes
|
|
188
|
+
check<unknown>().isUnknown() // passes
|
|
189
|
+
|
|
190
|
+
// Nullable/Optional
|
|
191
|
+
check<string | null>().isNullable() // passes
|
|
192
|
+
check<string | undefined>().isOptional() // passes
|
|
193
|
+
|
|
194
|
+
// Union/Tuple/Array
|
|
195
|
+
check<'a' | 'b'>().isUnion() // passes
|
|
196
|
+
check<[string, number]>().isTuple() // passes
|
|
197
|
+
check<string[]>().isArray() // passes
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### assert() - Strict type checking
|
|
201
|
+
|
|
202
|
+
Similar to `check()` but throws at compile time on failure with a clearer error message.
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
import { assert } from '@deessejs/type-testing'
|
|
206
|
+
|
|
207
|
+
// Fails with a clear error message
|
|
208
|
+
assert<string>().equals<number>() // compile error
|
|
209
|
+
assert<{ a: string }>().hasProperty('b') // compile error
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### expect() - BDD-style API
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
import { expect } from '@deessejs/type-testing'
|
|
216
|
+
|
|
217
|
+
// Compare two types
|
|
218
|
+
expect<string, string>().toBeEqual() // passes
|
|
219
|
+
expect<string, number>().toBeNotEqual() // passes
|
|
220
|
+
|
|
221
|
+
// Type extends
|
|
222
|
+
expect<string>().toExtend<string>() // passes
|
|
223
|
+
|
|
224
|
+
// Special types
|
|
225
|
+
expect<any>().toBeAny() // passes
|
|
226
|
+
expect<never>().toBeNever() // passes
|
|
227
|
+
|
|
228
|
+
// Nullable/Optional
|
|
229
|
+
expect<string | null>().toBeNullable() // passes
|
|
230
|
+
expect<string | undefined>().toBeOptional() // passes
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Compile-time Assertions
|
|
234
|
+
|
|
235
|
+
### ExpectTrue & ExpectEqual
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
import { ExpectTrue, ExpectEqual } from '@deessejs/type-testing'
|
|
239
|
+
|
|
240
|
+
// Assert a type is true
|
|
241
|
+
type Test1 = ExpectTrue<true> // true
|
|
242
|
+
|
|
243
|
+
// Assert equality - throws if not equal
|
|
244
|
+
type Test2 = ExpectEqual<string, string> // string
|
|
245
|
+
|
|
246
|
+
// Using with type tests
|
|
247
|
+
type IsString<T> = ExpectEqual<T, string>
|
|
248
|
+
type Result = IsString<string> // string (passes)
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### expectFalse
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
import { expectFalse } from '@deessejs/type-testing'
|
|
255
|
+
|
|
256
|
+
// Assert T is false at compile time
|
|
257
|
+
expectFalse<false>() // passes
|
|
258
|
+
expectFalse<true>() // compile error
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## API Reference
|
|
262
|
+
|
|
263
|
+
### Types
|
|
264
|
+
|
|
265
|
+
| Type | Description |
|
|
266
|
+
|------|-------------|
|
|
267
|
+
| `Equal<T, U>` | Strict equality check |
|
|
268
|
+
| `NotEqual<T, U>` | Inequality check |
|
|
269
|
+
| `SimpleEqual<T, U>` | Simple equality for plain types |
|
|
270
|
+
| `IsAny<T>` | Check if type is `any` |
|
|
271
|
+
| `IsNever<T>` | Check if type is `never` |
|
|
272
|
+
| `IsUnknown<T>` | Check if type is `unknown` |
|
|
273
|
+
| `IsVoid<T>` | Check if type is `void` |
|
|
274
|
+
| `IsUndefined<T>` | Check if type is `undefined` |
|
|
275
|
+
| `IsNull<T>` | Check if type is `null` |
|
|
276
|
+
| `IsNullable<T>` | Check if type is `null \| undefined` |
|
|
277
|
+
| `IsOptional<T>` | Check if type may be `undefined` |
|
|
278
|
+
| `IsUnion<T>` | Check if type is a union |
|
|
279
|
+
| `IsTuple<T>` | Check if type is a tuple |
|
|
280
|
+
| `IsArray<T>` | Check if type is an array |
|
|
281
|
+
| `IsInhabited<T>` | Check if type has at least one value |
|
|
282
|
+
| `IsUninhabited<T>` | Check if type has no values |
|
|
283
|
+
| `HasProperty<T, K>` | Check if type has property K |
|
|
284
|
+
| `PropertyType<T, K>` | Get type of property K |
|
|
285
|
+
| `Parameters<T>` | Get function parameters as tuple |
|
|
286
|
+
| `ReturnType<T>` | Get function return type |
|
|
287
|
+
| `Parameter<T, N>` | Get parameter at index N |
|
|
288
|
+
| `Length<T>` | Get tuple/array length |
|
|
289
|
+
| `ExpectTrue<T>` | Assert T is true |
|
|
290
|
+
| `ExpectEqual<T, U>` | Assert T equals U |
|
|
291
|
+
|
|
292
|
+
### Functions
|
|
293
|
+
|
|
294
|
+
| Function | Description |
|
|
295
|
+
|----------|-------------|
|
|
296
|
+
| `check<T>()` | Create a chainable type checker |
|
|
297
|
+
| `assert<T>()` | Create an assert type checker (throws on failure) |
|
|
298
|
+
| `expect<T, U>()` | Create an expect-style type checker |
|
|
299
|
+
| `expectFalse<T>()` | Assert T is false at compile time |
|
|
300
|
+
|
|
301
|
+
## License
|
|
302
|
+
|
|
303
|
+
MIT
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
body, html {
|
|
2
|
+
margin:0; padding: 0;
|
|
3
|
+
height: 100%;
|
|
4
|
+
}
|
|
5
|
+
body {
|
|
6
|
+
font-family: Helvetica Neue, Helvetica, Arial;
|
|
7
|
+
font-size: 14px;
|
|
8
|
+
color:#333;
|
|
9
|
+
}
|
|
10
|
+
.small { font-size: 12px; }
|
|
11
|
+
*, *:after, *:before {
|
|
12
|
+
-webkit-box-sizing:border-box;
|
|
13
|
+
-moz-box-sizing:border-box;
|
|
14
|
+
box-sizing:border-box;
|
|
15
|
+
}
|
|
16
|
+
h1 { font-size: 20px; margin: 0;}
|
|
17
|
+
h2 { font-size: 14px; }
|
|
18
|
+
pre {
|
|
19
|
+
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
-moz-tab-size: 2;
|
|
23
|
+
-o-tab-size: 2;
|
|
24
|
+
tab-size: 2;
|
|
25
|
+
}
|
|
26
|
+
a { color:#0074D9; text-decoration:none; }
|
|
27
|
+
a:hover { text-decoration:underline; }
|
|
28
|
+
.strong { font-weight: bold; }
|
|
29
|
+
.space-top1 { padding: 10px 0 0 0; }
|
|
30
|
+
.pad2y { padding: 20px 0; }
|
|
31
|
+
.pad1y { padding: 10px 0; }
|
|
32
|
+
.pad2x { padding: 0 20px; }
|
|
33
|
+
.pad2 { padding: 20px; }
|
|
34
|
+
.pad1 { padding: 10px; }
|
|
35
|
+
.space-left2 { padding-left:55px; }
|
|
36
|
+
.space-right2 { padding-right:20px; }
|
|
37
|
+
.center { text-align:center; }
|
|
38
|
+
.clearfix { display:block; }
|
|
39
|
+
.clearfix:after {
|
|
40
|
+
content:'';
|
|
41
|
+
display:block;
|
|
42
|
+
height:0;
|
|
43
|
+
clear:both;
|
|
44
|
+
visibility:hidden;
|
|
45
|
+
}
|
|
46
|
+
.fl { float: left; }
|
|
47
|
+
@media only screen and (max-width:640px) {
|
|
48
|
+
.col3 { width:100%; max-width:100%; }
|
|
49
|
+
.hide-mobile { display:none!important; }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.quiet {
|
|
53
|
+
color: #7f7f7f;
|
|
54
|
+
color: rgba(0,0,0,0.5);
|
|
55
|
+
}
|
|
56
|
+
.quiet a { opacity: 0.7; }
|
|
57
|
+
|
|
58
|
+
.fraction {
|
|
59
|
+
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
|
60
|
+
font-size: 10px;
|
|
61
|
+
color: #555;
|
|
62
|
+
background: #E8E8E8;
|
|
63
|
+
padding: 4px 5px;
|
|
64
|
+
border-radius: 3px;
|
|
65
|
+
vertical-align: middle;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
div.path a:link, div.path a:visited { color: #333; }
|
|
69
|
+
table.coverage {
|
|
70
|
+
border-collapse: collapse;
|
|
71
|
+
margin: 10px 0 0 0;
|
|
72
|
+
padding: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
table.coverage td {
|
|
76
|
+
margin: 0;
|
|
77
|
+
padding: 0;
|
|
78
|
+
vertical-align: top;
|
|
79
|
+
}
|
|
80
|
+
table.coverage td.line-count {
|
|
81
|
+
text-align: right;
|
|
82
|
+
padding: 0 5px 0 20px;
|
|
83
|
+
}
|
|
84
|
+
table.coverage td.line-coverage {
|
|
85
|
+
text-align: right;
|
|
86
|
+
padding-right: 10px;
|
|
87
|
+
min-width:20px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
table.coverage td span.cline-any {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
padding: 0 5px;
|
|
93
|
+
width: 100%;
|
|
94
|
+
}
|
|
95
|
+
.missing-if-branch {
|
|
96
|
+
display: inline-block;
|
|
97
|
+
margin-right: 5px;
|
|
98
|
+
border-radius: 3px;
|
|
99
|
+
position: relative;
|
|
100
|
+
padding: 0 4px;
|
|
101
|
+
background: #333;
|
|
102
|
+
color: yellow;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.skip-if-branch {
|
|
106
|
+
display: none;
|
|
107
|
+
margin-right: 10px;
|
|
108
|
+
position: relative;
|
|
109
|
+
padding: 0 4px;
|
|
110
|
+
background: #ccc;
|
|
111
|
+
color: white;
|
|
112
|
+
}
|
|
113
|
+
.missing-if-branch .typ, .skip-if-branch .typ {
|
|
114
|
+
color: inherit !important;
|
|
115
|
+
}
|
|
116
|
+
.coverage-summary {
|
|
117
|
+
border-collapse: collapse;
|
|
118
|
+
width: 100%;
|
|
119
|
+
}
|
|
120
|
+
.coverage-summary tr { border-bottom: 1px solid #bbb; }
|
|
121
|
+
.keyline-all { border: 1px solid #ddd; }
|
|
122
|
+
.coverage-summary td, .coverage-summary th { padding: 10px; }
|
|
123
|
+
.coverage-summary tbody { border: 1px solid #bbb; }
|
|
124
|
+
.coverage-summary td { border-right: 1px solid #bbb; }
|
|
125
|
+
.coverage-summary td:last-child { border-right: none; }
|
|
126
|
+
.coverage-summary th {
|
|
127
|
+
text-align: left;
|
|
128
|
+
font-weight: normal;
|
|
129
|
+
white-space: nowrap;
|
|
130
|
+
}
|
|
131
|
+
.coverage-summary th.file { border-right: none !important; }
|
|
132
|
+
.coverage-summary th.pct { }
|
|
133
|
+
.coverage-summary th.pic,
|
|
134
|
+
.coverage-summary th.abs,
|
|
135
|
+
.coverage-summary td.pct,
|
|
136
|
+
.coverage-summary td.abs { text-align: right; }
|
|
137
|
+
.coverage-summary td.file { white-space: nowrap; }
|
|
138
|
+
.coverage-summary td.pic { min-width: 120px !important; }
|
|
139
|
+
.coverage-summary tfoot td { }
|
|
140
|
+
|
|
141
|
+
.coverage-summary .sorter {
|
|
142
|
+
height: 10px;
|
|
143
|
+
width: 7px;
|
|
144
|
+
display: inline-block;
|
|
145
|
+
margin-left: 0.5em;
|
|
146
|
+
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
|
147
|
+
}
|
|
148
|
+
.coverage-summary .sorted .sorter {
|
|
149
|
+
background-position: 0 -20px;
|
|
150
|
+
}
|
|
151
|
+
.coverage-summary .sorted-desc .sorter {
|
|
152
|
+
background-position: 0 -10px;
|
|
153
|
+
}
|
|
154
|
+
.status-line { height: 10px; }
|
|
155
|
+
/* yellow */
|
|
156
|
+
.cbranch-no { background: yellow !important; color: #111; }
|
|
157
|
+
/* dark red */
|
|
158
|
+
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
|
|
159
|
+
.low .chart { border:1px solid #C21F39 }
|
|
160
|
+
.highlighted,
|
|
161
|
+
.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
|
|
162
|
+
background: #C21F39 !important;
|
|
163
|
+
}
|
|
164
|
+
/* medium red */
|
|
165
|
+
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
|
|
166
|
+
/* light red */
|
|
167
|
+
.low, .cline-no { background:#FCE1E5 }
|
|
168
|
+
/* light green */
|
|
169
|
+
.high, .cline-yes { background:rgb(230,245,208) }
|
|
170
|
+
/* medium green */
|
|
171
|
+
.cstat-yes { background:rgb(161,215,106) }
|
|
172
|
+
/* dark green */
|
|
173
|
+
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
|
|
174
|
+
.high .chart { border:1px solid rgb(77,146,33) }
|
|
175
|
+
/* dark yellow (gold) */
|
|
176
|
+
.status-line.medium, .medium .cover-fill { background: #f9cd0b; }
|
|
177
|
+
.medium .chart { border:1px solid #f9cd0b; }
|
|
178
|
+
/* light yellow */
|
|
179
|
+
.medium { background: #fff4c2; }
|
|
180
|
+
|
|
181
|
+
.cstat-skip { background: #ddd; color: #111; }
|
|
182
|
+
.fstat-skip { background: #ddd; color: #111 !important; }
|
|
183
|
+
.cbranch-skip { background: #ddd !important; color: #111; }
|
|
184
|
+
|
|
185
|
+
span.cline-neutral { background: #eaeaea; }
|
|
186
|
+
|
|
187
|
+
.coverage-summary td.empty {
|
|
188
|
+
opacity: .5;
|
|
189
|
+
padding-top: 4px;
|
|
190
|
+
padding-bottom: 4px;
|
|
191
|
+
line-height: 1;
|
|
192
|
+
color: #888;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.cover-fill, .cover-empty {
|
|
196
|
+
display:inline-block;
|
|
197
|
+
height: 12px;
|
|
198
|
+
}
|
|
199
|
+
.chart {
|
|
200
|
+
line-height: 0;
|
|
201
|
+
}
|
|
202
|
+
.cover-empty {
|
|
203
|
+
background: white;
|
|
204
|
+
}
|
|
205
|
+
.cover-full {
|
|
206
|
+
border-right: none !important;
|
|
207
|
+
}
|
|
208
|
+
pre.prettyprint {
|
|
209
|
+
border: none !important;
|
|
210
|
+
padding: 0 !important;
|
|
211
|
+
margin: 0 !important;
|
|
212
|
+
}
|
|
213
|
+
.com { color: #999 !important; }
|
|
214
|
+
.ignore-none { color: #999; font-weight: normal; }
|
|
215
|
+
|
|
216
|
+
.wrapper {
|
|
217
|
+
min-height: 100%;
|
|
218
|
+
height: auto !important;
|
|
219
|
+
height: 100%;
|
|
220
|
+
margin: 0 auto -48px;
|
|
221
|
+
}
|
|
222
|
+
.footer, .push {
|
|
223
|
+
height: 48px;
|
|
224
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
var jumpToCode = (function init() {
|
|
3
|
+
// Classes of code we would like to highlight in the file view
|
|
4
|
+
var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
|
|
5
|
+
|
|
6
|
+
// Elements to highlight in the file listing view
|
|
7
|
+
var fileListingElements = ['td.pct.low'];
|
|
8
|
+
|
|
9
|
+
// We don't want to select elements that are direct descendants of another match
|
|
10
|
+
var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
|
|
11
|
+
|
|
12
|
+
// Selector that finds elements on the page to which we can jump
|
|
13
|
+
var selector =
|
|
14
|
+
fileListingElements.join(', ') +
|
|
15
|
+
', ' +
|
|
16
|
+
notSelector +
|
|
17
|
+
missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
|
|
18
|
+
|
|
19
|
+
// The NodeList of matching elements
|
|
20
|
+
var missingCoverageElements = document.querySelectorAll(selector);
|
|
21
|
+
|
|
22
|
+
var currentIndex;
|
|
23
|
+
|
|
24
|
+
function toggleClass(index) {
|
|
25
|
+
missingCoverageElements
|
|
26
|
+
.item(currentIndex)
|
|
27
|
+
.classList.remove('highlighted');
|
|
28
|
+
missingCoverageElements.item(index).classList.add('highlighted');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function makeCurrent(index) {
|
|
32
|
+
toggleClass(index);
|
|
33
|
+
currentIndex = index;
|
|
34
|
+
missingCoverageElements.item(index).scrollIntoView({
|
|
35
|
+
behavior: 'smooth',
|
|
36
|
+
block: 'center',
|
|
37
|
+
inline: 'center'
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function goToPrevious() {
|
|
42
|
+
var nextIndex = 0;
|
|
43
|
+
if (typeof currentIndex !== 'number' || currentIndex === 0) {
|
|
44
|
+
nextIndex = missingCoverageElements.length - 1;
|
|
45
|
+
} else if (missingCoverageElements.length > 1) {
|
|
46
|
+
nextIndex = currentIndex - 1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
makeCurrent(nextIndex);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function goToNext() {
|
|
53
|
+
var nextIndex = 0;
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
typeof currentIndex === 'number' &&
|
|
57
|
+
currentIndex < missingCoverageElements.length - 1
|
|
58
|
+
) {
|
|
59
|
+
nextIndex = currentIndex + 1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
makeCurrent(nextIndex);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return function jump(event) {
|
|
66
|
+
if (
|
|
67
|
+
document.getElementById('fileSearch') === document.activeElement &&
|
|
68
|
+
document.activeElement != null
|
|
69
|
+
) {
|
|
70
|
+
// if we're currently focused on the search input, we don't want to navigate
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
switch (event.which) {
|
|
75
|
+
case 78: // n
|
|
76
|
+
case 74: // j
|
|
77
|
+
goToNext();
|
|
78
|
+
break;
|
|
79
|
+
case 66: // b
|
|
80
|
+
case 75: // k
|
|
81
|
+
case 80: // p
|
|
82
|
+
goToPrevious();
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
})();
|
|
87
|
+
window.addEventListener('keydown', jumpToCode);
|