@webergency-utils/typechecker 0.1.8 → 0.1.10

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.
@@ -1,24 +1,24 @@
1
1
  export type LowerCase = {
2
- readonly __transform_lowercase: true;
2
+ readonly __transform_lowercase?: true;
3
3
  };
4
4
  export type UpperCase = {
5
- readonly __transform_uppercase: true;
5
+ readonly __transform_uppercase?: true;
6
6
  };
7
7
  export type Trim = {
8
- readonly __transform_trim: true;
8
+ readonly __transform_trim?: true;
9
9
  };
10
10
  export type Capitalize = {
11
- readonly __transform_capitalize: true;
11
+ readonly __transform_capitalize?: true;
12
12
  };
13
13
  export type ToNumber = {
14
- readonly __transform_tonumber: true;
14
+ readonly __transform_tonumber?: true;
15
15
  };
16
16
  export type ToBoolean = {
17
- readonly __transform_toboolean: true;
17
+ readonly __transform_toboolean?: true;
18
18
  };
19
19
  export type ToDate = {
20
- readonly __transform_todate: true;
20
+ readonly __transform_todate?: true;
21
21
  };
22
22
  export type Custom<Fn extends (val: any) => any> = {
23
- readonly __transform_custom: Fn;
23
+ readonly __transform_custom?: Fn;
24
24
  };
@@ -42,18 +42,15 @@ type ApplyModifiers<T, EntriesList extends any[]> = EntriesList extends [[infer
42
42
  * Utility type to decorate nested properties of a type with validation/transform modifiers without retyping the structure.
43
43
  */
44
44
  export type WithModifiers<T, M> = ApplyModifiers<T, TuplifyUnion<Entries<M>>>;
45
+ type IsAny<T> = 0 extends 1 & T ? true : false;
45
46
  /**
46
47
  * Recursively resolves object properties, removing the optional `?` modifier
47
48
  * from any properties that have a `tag.Default` applied.
48
49
  */
49
50
  export type ResolveDefaults<T> = T extends Date | symbol | string | number | boolean | bigint | null | undefined | Function ? T : T extends Array<infer U> ? Array<ResolveDefaults<U>> : T extends object ? {
50
- [K in keyof T as NonNullable<T[K]> extends {
51
- readonly __default: any;
52
- } ? K : never]-?: ResolveDefaults<Exclude<T[K], undefined>>;
51
+ [K in keyof T as IsAny<T[K]> extends true ? never : '__default' extends keyof NonNullable<T[K]> ? K : never]-?: ResolveDefaults<Exclude<T[K], undefined>>;
53
52
  } & {
54
- [K in keyof T as NonNullable<T[K]> extends {
55
- readonly __default: any;
56
- } ? never : K]: ResolveDefaults<T[K]>;
53
+ [K in keyof T as IsAny<T[K]> extends true ? K : '__default' extends keyof NonNullable<T[K]> ? never : K]: ResolveDefaults<T[K]>;
57
54
  } extends infer O ? {
58
55
  [K in keyof O]: O[K];
59
56
  } : never : T;
@@ -2,9 +2,11 @@ import ts from './ts.js';
2
2
  import { buildValidator, generateHash, buildJsonSchema, objectToAst } from './engine/resolver.js';
3
3
  export { buildValidator, generateHash, buildJsonSchema } from './engine/resolver.js';
4
4
  import { hoistRegistrations } from './engine/hoister.js';
5
+ import { installStaticConstraintDiagnostics } from './engine/staticAsserts.js';
5
6
  const RUNTIME_FUNCTIONS = ['is', 'assert', 'assertGuard', 'validate', 'jsonSchema'];
6
7
  export default function transformer(program) {
7
8
  const checker = program.getTypeChecker();
9
+ installStaticConstraintDiagnostics(program);
8
10
  return (context) => {
9
11
  return (sourceFile) => {
10
12
  const validatorCache = new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webergency-utils/typechecker",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "description": "TypeScript compiler plugin for runtime validation",
6
6
  "author": "radixxko",
@@ -24,6 +24,12 @@
24
24
  "import": "./dist/transformer.js",
25
25
  "require": "./dist/transformer.js",
26
26
  "default": "./dist/transformer.js"
27
+ },
28
+ "./plugin": {
29
+ "types": "./dist/plugin.d.ts",
30
+ "import": "./dist/plugin.js",
31
+ "require": "./dist/plugin.js",
32
+ "default": "./dist/plugin.js"
27
33
  }
28
34
  },
29
35
  "files": [
@@ -31,11 +37,11 @@
31
37
  ],
32
38
  "scripts": {
33
39
  "lint": "eslint .",
40
+ "test": "vitest run",
41
+ "coverage": "vitest run --coverage",
34
42
  "clean": "rm -rf ./dist/* node_modules package-lock.json && npm i",
35
- "commit": "node -e \"const version = require('./package.json').version.trim(); require('child_process').execSync('git add . && git commit -m \\\"Version ' + version + '\\\"');\"",
36
43
  "build": "npm run clean && tsc && node update_imports.js",
37
- "test": "vitest run",
38
- "test:coverage": "vitest run --coverage",
44
+ "commit": "node -e \"const version = require('./package.json').version.trim(); require('child_process').execSync('git add . && git commit -m \\\"Version ' + version + '\\\"');\"",
39
45
  "version": "npm run build && npm publish --access public && npm run commit && git push"
40
46
  },
41
47
  "repository": {
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 webergency-utils
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.