@signpostmarv/ts-assert 0.1.1--develop → 0.1.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/.github/FUNDING.yml +2 -0
- package/.github/workflows/ci.yml +25 -0
- package/README.md +65 -7
- package/generated/assertions.d.ts +520 -0
- package/generated/assertions.js +1037 -0
- package/generated/assertions.js.map +1 -0
- package/lib/main.d.ts +269 -0
- package/lib/main.js +18 -0
- package/lib/main.js.map +1 -0
- package/lib/main.ts +39 -0
- package/package.json +3 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
basic-checks:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/setup-node@v4
|
|
13
|
+
with:
|
|
14
|
+
node-version: 21.x
|
|
15
|
+
cache: 'npm'
|
|
16
|
+
- run: npm ci
|
|
17
|
+
- run: make lint
|
|
18
|
+
- name: Generate coverage
|
|
19
|
+
run: ./node_modules/.bin/c8 --config=./.c8rc.coveralls.json npm test
|
|
20
|
+
env:
|
|
21
|
+
NODE_OPTIONS: '--enable-source-maps --no-warnings=ExperimentalWarning --loader ts-node/esm'
|
|
22
|
+
- name: Coveralls GitHub Action
|
|
23
|
+
uses: coverallsapp/github-action@v2.2.3
|
|
24
|
+
with:
|
|
25
|
+
file: './coverage/lcov.info'
|
package/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
[](https://coveralls.io/github/SignpostMarv/ts-assert?branch=main)
|
|
2
|
+
[](https://github.com/SignpostMarv/ts-assert/actions/workflows/ci.yml?query=branch%3Amain)
|
|
3
|
+
|
|
1
4
|
# @signpostmarv/ts-assert
|
|
2
5
|
|
|
3
6
|
Code-generated assertions for TypeScript type guarding functions.
|
|
@@ -6,18 +9,73 @@ Code-generated assertions for TypeScript type guarding functions.
|
|
|
6
9
|
|
|
7
10
|
```ts
|
|
8
11
|
import {describe, it} from 'node:test';
|
|
12
|
+
import assert from 'node:assert/strict';
|
|
9
13
|
import ts_assert from '@signpostmarv/ts-assert';
|
|
10
14
|
import ts from 'typescript';
|
|
11
15
|
|
|
12
|
-
void describe('
|
|
13
|
-
void it('
|
|
14
|
-
assert.
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
void describe('isIdentifier', () => {
|
|
17
|
+
void it('throws', () => {
|
|
18
|
+
assert.throws(() =>
|
|
19
|
+
ts_assert.isIdentifier(ts.factory.createStringLiteral('foo'))
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
void describe('isEmptyBindingPattern', () => {
|
|
25
|
+
void it('throws', () => {
|
|
26
|
+
assert.throws(() =>
|
|
27
|
+
ts_assert.isEmptyBindingPattern(ts.factory.createIdentifier('foo'))
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
void describe('isBooleanLiteral', () => {
|
|
33
|
+
void it('throws', () => {
|
|
34
|
+
assert.throws(() =>
|
|
35
|
+
ts_assert.isBooleanLiteral(
|
|
36
|
+
ts.factory.createStringLiteral('foo'),
|
|
37
|
+
true
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
assert.throws(() =>
|
|
41
|
+
ts_assert.isBooleanLiteral(ts.factory.createFalse(), true)
|
|
42
|
+
);
|
|
43
|
+
assert.throws(() =>
|
|
44
|
+
ts_assert.isBooleanLiteral(ts.factory.createTrue(), false)
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
void it('does not throw', () => {
|
|
48
|
+
assert.doesNotThrow(() =>
|
|
49
|
+
ts_assert.isBooleanLiteral(ts.factory.createTrue(), true)
|
|
50
|
+
);
|
|
51
|
+
assert.doesNotThrow(() =>
|
|
52
|
+
ts_assert.isBooleanLiteral(ts.factory.createFalse(), false)
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
void describe('isTokenWithExpectedKind', () => {
|
|
58
|
+
void it('throws', () => {
|
|
59
|
+
assert.throws(() =>
|
|
60
|
+
ts_assert.isTokenWithExpectedKind(
|
|
61
|
+
ts.factory.createStringLiteral('foo'),
|
|
62
|
+
ts.SyntaxKind.StringKeyword
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
assert.throws(() =>
|
|
66
|
+
ts_assert.isTokenWithExpectedKind(
|
|
67
|
+
ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
|
|
68
|
+
ts.SyntaxKind.NumberKeyword
|
|
69
|
+
)
|
|
17
70
|
);
|
|
18
71
|
});
|
|
19
|
-
void it('
|
|
20
|
-
|
|
72
|
+
void it('does not throw', () => {
|
|
73
|
+
assert.doesNotThrow(() =>
|
|
74
|
+
ts_assert.isTokenWithExpectedKind(
|
|
75
|
+
ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
|
|
76
|
+
ts.SyntaxKind.StringKeyword
|
|
77
|
+
)
|
|
78
|
+
);
|
|
21
79
|
});
|
|
22
80
|
});
|
|
23
81
|
```
|