@signpostmarv/ts-assert 0.4.1 → 0.4.3

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EACjB,YAAY,EACZ,YAAY,GACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAQxC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,UAAU,gBAAgB,CAC/B,IAAU,EACV,IAAa,EACb,OAAwB;IAExB,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE5B,8CAA8C;IAC9C,yFAAyF;IACzF,MAAM,CAAC,KAAK,CACX,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,EAC7D,OAAO,CACP,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB,CACtC,KAAW,EACX,aAA4B,EAC5B,OAAwB;IAExB,8CAA8C;IAC9C,yFAAyF;IACzF,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAE/C,8CAA8C;IAC9C,yFAAyF;IACzF,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAExD,8CAA8C;IAC9C,yFAAyF;IACzF,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,oBAAoB,CACnC,KAAW,EACX,QAAW,EACX,OAAwB;IAExB,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAE7B,8CAA8C;IAC9C,yFAAyF;IACzF,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,WAAW,CAC1B,KAAW,EACX,OAAwB;IAExB,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC;AAED,eAAe;IACd,GAAG,SAAS;IACZ,gBAAgB;IAChB,uBAAuB;IACvB,oBAAoB;IACpB,WAAW;CACX,CAAC"}
package/lib/main.ts ADDED
@@ -0,0 +1,74 @@
1
+ import generated, {
2
+ isExpression,
3
+ isIdentifier,
4
+ } from '../generated/assertions.ts';
5
+ import assert from 'node:assert/strict';
6
+ import type {
7
+ FalseLiteral,
8
+ Identifier,
9
+ Node,
10
+ TrueLiteral,
11
+ TypeNode,
12
+ } from 'typescript';
13
+ import ts from 'typescript';
14
+
15
+ export function isBooleanLiteral(
16
+ node: Node,
17
+ type: boolean,
18
+ message?: string | Error,
19
+ ): asserts node is typeof type extends true ? TrueLiteral : FalseLiteral {
20
+ isExpression(node, message);
21
+
22
+ // oxlint-disable-next-line @stylistic/max-len
23
+ // oxlint-disable-next-line typescript/no-unsafe-call, typescript/no-unsafe-member-access
24
+ assert.equal(
25
+ node.kind,
26
+ type ? ts.SyntaxKind.TrueKeyword : ts.SyntaxKind.FalseKeyword,
27
+ message,
28
+ );
29
+ }
30
+
31
+ export function isTokenWithExpectedKind(
32
+ maybe: Node,
33
+ expected_kind: ts.SyntaxKind,
34
+ message?: string | Error,
35
+ ): asserts maybe is TypeNode & {kind: typeof expected_kind} {
36
+ // oxlint-disable-next-line @stylistic/max-len
37
+ // oxlint-disable-next-line typescript/no-unsafe-call, typescript/no-unsafe-member-access
38
+ assert.equal(ts.isToken(maybe), true, message);
39
+
40
+ // oxlint-disable-next-line @stylistic/max-len
41
+ // oxlint-disable-next-line typescript/no-unsafe-call, typescript/no-unsafe-member-access
42
+ assert.equal(ts.isTokenKind(maybe.kind), true, message);
43
+
44
+ // oxlint-disable-next-line @stylistic/max-len
45
+ // oxlint-disable-next-line typescript/no-unsafe-call, typescript/no-unsafe-member-access
46
+ assert.equal(maybe.kind, expected_kind, message);
47
+ }
48
+
49
+ export function isExpectedIdentifier<T = string>(
50
+ maybe: Node,
51
+ expected: T,
52
+ message?: string | Error,
53
+ ): asserts maybe is Identifier & {escapedText: T} {
54
+ isIdentifier(maybe, message);
55
+
56
+ // oxlint-disable-next-line @stylistic/max-len
57
+ // oxlint-disable-next-line typescript/no-unsafe-call, typescript/no-unsafe-member-access
58
+ assert.equal(maybe.escapedText, expected, message);
59
+ }
60
+
61
+ export function isUndefined(
62
+ maybe: Node,
63
+ message?: string | Error,
64
+ ): asserts maybe is Identifier & {escapedText: 'undefined'} {
65
+ isExpectedIdentifier(maybe, 'undefined', message);
66
+ }
67
+
68
+ export default {
69
+ ...generated,
70
+ isBooleanLiteral,
71
+ isTokenWithExpectedKind,
72
+ isExpectedIdentifier,
73
+ isUndefined,
74
+ };
package/package.json CHANGED
@@ -8,25 +8,29 @@
8
8
  "url": "git+https://github.com/SignpostMarv/ts-assert.git"
9
9
  },
10
10
  "funding": "https://github.com/SignpostMarv/ts-assert?sponsor=1",
11
- "scripts": {
12
- "test": "ts-node ./tests.ts"
13
- },
14
11
  "exports": {
15
12
  ".": "./lib/main.js"
16
13
  },
17
14
  "types": "./lib/main.d.ts",
15
+ "files": [
16
+ "./lib/**/*.js",
17
+ "./lib/**/*.ts",
18
+ "./lib/**/*.js.map",
19
+ "./generated/**/*.js",
20
+ "./generated/**/*.ts",
21
+ "./generated/**/*.js.map"
22
+ ],
18
23
  "devDependencies": {
19
- "@signpostmarv/eslint-config": "^0.4.0",
20
- "@types/eslint": "^9.6.1",
21
- "@types/node": "^24.3.1",
22
- "c8": "^10.1.2",
23
- "eslint": "^9.34.0",
24
- "prettier": "^3.2.5",
25
- "ts-node": "^10.9.2",
26
- "typescript-eslint": "^8.42.0"
24
+ "@signpostmarv/oxlint-config": "^0.2.0",
25
+ "@stylistic/eslint-plugin": "^5.10.0",
26
+ "@types/node": "^25.5.0",
27
+ "@types/regexp.escape": "^2.0.0",
28
+ "oxlint": "^1.57.0",
29
+ "oxlint-tsgolint": "^0.18.1",
30
+ "prettier": "^3.2.5"
27
31
  },
28
32
  "dependencies": {
29
- "typescript": "~5.9.2"
33
+ "typescript": "~5.9.3"
30
34
  },
31
- "version": "0.4.1"
35
+ "version": "0.4.3"
32
36
  }