@webergency-utils/typechecker 0.1.1 → 0.1.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.
@@ -1,4 +1,4 @@
1
- import * as ts from 'typescript';
1
+ import ts from '../ts.js';
2
2
  export interface IValidationRegistry {
3
3
  validators: Map<string, ts.Expression>;
4
4
  }
@@ -1,4 +1,4 @@
1
- import * as ts from 'typescript';
1
+ import ts from '../ts.js';
2
2
  export function createRegistry() {
3
3
  return {
4
4
  validators: new Map()
@@ -1,2 +1,2 @@
1
- import ts from 'typescript';
1
+ import ts from '../ts.js';
2
2
  export declare function hoistRegistrations(sourceFile: ts.SourceFile, cache: Map<string, ts.Expression>, requiredUtils: Set<string>, schemasMap?: Map<string, ts.Expression>): ts.SourceFile;
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import ts from '../ts.js';
2
2
  export function hoistRegistrations(sourceFile, cache, requiredUtils, schemasMap) {
3
3
  if (cache.size === 0 && requiredUtils.size === 0) {
4
4
  return sourceFile;
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import ts from '../ts.js';
2
2
  export declare function buildValidator(type: ts.Type, checker: ts.TypeChecker, validatorsMap: Map<string, ts.Expression>, requiredUtils: Set<string>): ts.Expression;
3
3
  export declare function generateHash(type: ts.Type, checker: ts.TypeChecker): string;
4
4
  export declare function objectToAst(val: any): ts.Expression;
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import ts from '../ts.js';
2
2
  import { createPrimitiveCheck, createLiteralCheck, createArrayCheck, createUnionCheck, createObjectCheck, createDateCheck, createNullCheck, createUndefinedCheck, createIntersectionCheck, createTupleCheck, createRecordCheck, createRegExpCheck, createTemplateLiteralCheck, createConstrainedPrimitiveCheck, createSetCheck, createMapCheck } from './generators.js';
3
3
  import { createHash } from 'crypto';
4
4
  function getStringLiteralValue(type) {
@@ -1,3 +1,3 @@
1
- import ts from 'typescript';
1
+ import ts from './ts.js';
2
2
  export { buildValidator, generateHash, buildJsonSchema } from './engine/resolver.js';
3
3
  export default function transformer(program: ts.Program): (context: ts.TransformationContext) => (sourceFile: ts.SourceFile) => ts.SourceFile;
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ 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';
package/dist/ts.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type * as ts6Types from '@typescript/typescript6';
2
+ declare const ts: typeof ts6Types;
3
+ export default ts;
package/dist/ts.js ADDED
@@ -0,0 +1,13 @@
1
+ import * as tsModule from 'typescript';
2
+ let tsInstance = tsModule;
3
+ if (!tsInstance.createProgram) {
4
+ try {
5
+ const ts6 = await import('@typescript/typescript6');
6
+ tsInstance = ts6.default || ts6;
7
+ }
8
+ catch (e) {
9
+ // Ignore
10
+ }
11
+ }
12
+ const ts = tsInstance;
13
+ export default ts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webergency-utils/typechecker",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "TypeScript compiler plugin for runtime validation",
6
6
  "author": "radixxko",
@@ -33,7 +33,7 @@
33
33
  "lint": "eslint .",
34
34
  "clean": "rm -rf ./dist/* node_modules package-lock.json && npm i",
35
35
  "commit": "node -e \"const version = require('./package.json').version.trim(); require('child_process').execSync('git add . && git commit -m \\\"Version ' + version + '\\\"');\"",
36
- "build": "npm run clean && tsc",
36
+ "build": "npm run clean && tsc && node update_imports.js",
37
37
  "test": "vitest run",
38
38
  "test:coverage": "vitest run --coverage",
39
39
  "version": "npm run build && npm publish --access public && npm run commit && git push"
@@ -53,9 +53,10 @@
53
53
  "@eslint/js": "^10.0.1",
54
54
  "@stylistic/eslint-plugin": "^5.10.0",
55
55
  "@types/node": "^24.10.1",
56
+ "@typescript/typescript6": "^6.0.2",
56
57
  "@vitest/coverage-v8": "^4.1.6",
57
58
  "eslint": "^10.4.1",
58
- "typescript": "^6.0.3",
59
+ "typescript": "^6.0.3 || ^7.0.0",
59
60
  "typescript-eslint": "^8.60.0",
60
61
  "vitest": "^4.1.6"
61
62
  }