Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@deepkit/type-compiler

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deepkit/type-compiler - npm Package Compare versions

Comparing version 1.0.1-alpha.108 to 1.0.1-alpha.109

compiler-debug.ts

13

CHANGELOG.md

@@ -6,2 +6,15 @@ # Change Log

## [1.0.1-alpha.109](https://github.com/deepkit/deepkit-framework/compare/v1.0.1-alpha.108...v1.0.1-alpha.109) (2024-01-10)
### Bug Fixes
* **type-compiler:** arrow function receive type ([#521](https://github.com/deepkit/deepkit-framework/issues/521)) ([6bfb246](https://github.com/deepkit/deepkit-framework/commit/6bfb2466753bb99020d8f429097ad1cb3520e500))
* **type-compiler:** resolve reflection mode paths correctly ([acb2d72](https://github.com/deepkit/deepkit-framework/commit/acb2d72f242a742fe99fdcf9fba892faea701e08))
* **type-compiler:** set ts compiler options target to es2022 if higher than es20222 when resolving global lib files ([#516](https://github.com/deepkit/deepkit-framework/issues/516)) ([29a1a17](https://github.com/deepkit/deepkit-framework/commit/29a1a17c0092c6304497c28184d8c5b8790b35e5))
## [1.0.1-alpha.108](https://github.com/deepkit/deepkit-framework/compare/v1.0.1-alpha.107...v1.0.1-alpha.108) (2023-11-21)

@@ -8,0 +21,0 @@

1

dist/cjs/index.d.ts
import type { Program } from 'typescript';
export * from './src/compiler.js';
export * from './src/plugin.js';
export * from './src/loader.js';

@@ -4,0 +5,0 @@ export default function myTransformerPlugin(program: Program, opts: {}): {

@@ -28,2 +28,3 @@ "use strict";

__exportStar(require("./src/compiler.js"), exports);
__exportStar(require("./src/plugin.js"), exports);
__exportStar(require("./src/loader.js"), exports);

@@ -30,0 +31,0 @@ function myTransformerPlugin(program, opts) {

21

dist/cjs/src/compiler.d.ts

@@ -6,3 +6,3 @@ import type { __String, ArrowFunction, Bundle, ClassDeclaration, ClassExpression, CompilerHost, CompilerOptions, ConstructorDeclaration, CustomTransformer, CustomTransformerFactory, Declaration, EntityName, EnumDeclaration, ExportDeclaration, Expression, ExpressionWithTypeArguments, FunctionDeclaration, FunctionExpression, Identifier, ImportDeclaration, InterfaceDeclaration, MethodDeclaration, ModuleDeclaration, Node, NodeFactory, ParseConfigHost, PropertyAccessExpression, QualifiedName, Statement, TransformationContext, TypeAliasDeclaration, TypeChecker, TypeParameterDeclaration, TypeReferenceNode } from 'typescript';

import { ReflectionOp } from '@deepkit/type-spec';
import { Resolver } from './resolver.js';
import { ReflectionMode, reflectionModes, Resolver } from './resolver.js';
export declare function isObject(obj: any): obj is {

@@ -17,3 +17,2 @@ [key: string]: any;

export declare const packSize: number;
declare const reflectionModes: readonly ["always", "default", "never"];
interface ReflectionOptions {

@@ -125,3 +124,3 @@ /**

*/
protected compileDeclarations: Map<InterfaceDeclaration | TypeAliasDeclaration | EnumDeclaration, {
protected compileDeclarations: Map<TypeAliasDeclaration | InterfaceDeclaration | EnumDeclaration, {
name: EntityName;

@@ -172,3 +171,5 @@ sourceFile: SourceFile;

transformSourceFile(sourceFile: SourceFile): SourceFile;
protected injectResetΩ<T extends FunctionDeclaration | FunctionExpression | MethodDeclaration | ConstructorDeclaration>(node: T): T;
protected getModuleType(): 'cjs' | 'esm';
protected getArrowFunctionΩPropertyAccessIdentifier(node: ArrowFunction): Identifier;
protected injectResetΩ<T extends FunctionDeclaration | FunctionExpression | MethodDeclaration | ConstructorDeclaration | ArrowFunction>(node: T): T;
protected createProgramVarFromNode(node: Node, name: EntityName, sourceFile: SourceFile): Statement[];

@@ -281,3 +282,3 @@ protected extractPackStructOfType(node: Node | Declaration | ClassDeclaration | ClassExpression, program: CompilerProgram): void;

*/
protected decorateFunctionExpression(expression: FunctionExpression): FunctionExpression | ts.CallExpression;
protected decorateFunctionExpression(expression: FunctionExpression): ts.CallExpression | FunctionExpression;
/**

@@ -288,8 +289,8 @@ * function name() {}

*/
protected decorateFunctionDeclaration(declaration: FunctionDeclaration): FunctionDeclaration | ts.ExportAssignment | Statement[] | undefined;
protected decorateFunctionDeclaration(declaration: FunctionDeclaration): Statement[] | FunctionDeclaration | ts.ExportAssignment | undefined;
/**
* const fn = () => { }
* => const fn = Object.assign(() => {}, {__type: 34})
* const fn = () => {}
* => const fn = __assignType(() => {}, [34])
*/
protected decorateArrow(expression: ArrowFunction): ArrowFunction | ts.CallExpression;
protected decorateArrowFunction(expression: ArrowFunction): ts.CallExpression | ArrowFunction;
/**

@@ -303,3 +304,3 @@ * Object.assign(fn, {__type: []}) is much slower than a custom implementation like

protected wrapWithAssignType(fn: Expression, type: Expression): ts.CallExpression;
protected parseReflectionMode(mode: typeof reflectionModes[number] | '' | boolean | string | string[] | undefined, configPathDir: string): typeof reflectionModes[number];
protected parseReflectionMode(mode: ReflectionMode, configPathDir: string): typeof reflectionModes[number];
protected resolvedTsConfig: {

@@ -306,0 +307,0 @@ [path: string]: {

import type { CompilerHost, CompilerOptions, ExportDeclaration, ImportDeclaration, ResolvedModule, SourceFile } from 'typescript';
export declare const reflectionModes: readonly ["always", "default", "never"];
export type ReflectionMode = typeof reflectionModes[number] | '' | boolean | string | string[] | undefined;
export declare function patternMatch(path: string, patterns: string[], base?: string): boolean;
export declare function reflectionModeMatcher(filePath: string, mode: ReflectionMode, configPathDir?: string): typeof reflectionModes[number];
/**

@@ -3,0 +7,0 @@ * A utility to resolve a module path and its declaration.

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,5 +29,36 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.Resolver = void 0;
exports.Resolver = exports.reflectionModeMatcher = exports.patternMatch = exports.reflectionModes = void 0;
const typescript_1 = __importDefault(require("typescript"));
const micromatch = __importStar(require("micromatch"));
const path_1 = require("path");
const { createSourceFile, resolveModuleName, SyntaxKind, ScriptTarget, } = typescript_1.default;
exports.reflectionModes = ['always', 'default', 'never'];
function patternMatch(path, patterns, base) {
const normalized = patterns.map(v => {
if (v[0] === '!') {
if (!(0, path_1.isAbsolute)(v.slice(1)))
return `!${base}/${v.substr(1)}`;
return v;
}
if (!(0, path_1.isAbsolute)(v))
return `${base}/${v}`;
return v;
});
const matched = micromatch.default([path], normalized, {});
return matched.length > 0;
}
exports.patternMatch = patternMatch;
function reflectionModeMatcher(filePath, mode, configPathDir) {
if (Array.isArray(mode)) {
if (!configPathDir)
return 'never';
return patternMatch(filePath, mode, configPathDir) ? 'default' : 'never';
}
if ('boolean' === typeof mode)
return mode ? 'default' : 'never';
if (mode === 'default' || mode === 'always')
return mode;
return 'never';
}
exports.reflectionModeMatcher = reflectionModeMatcher;
/**

@@ -11,0 +65,0 @@ * A utility to resolve a module path and its declaration.

import type { Program } from 'typescript';
export * from './src/compiler.js';
export * from './src/plugin.js';
export * from './src/loader.js';

@@ -4,0 +5,0 @@ export default function myTransformerPlugin(program: Program, opts: {}): {

@@ -12,2 +12,3 @@ /*

export * from './src/compiler.js';
export * from './src/plugin.js';
export * from './src/loader.js';

@@ -14,0 +15,0 @@ export default function myTransformerPlugin(program, opts) {

@@ -6,3 +6,3 @@ import type { __String, ArrowFunction, Bundle, ClassDeclaration, ClassExpression, CompilerHost, CompilerOptions, ConstructorDeclaration, CustomTransformer, CustomTransformerFactory, Declaration, EntityName, EnumDeclaration, ExportDeclaration, Expression, ExpressionWithTypeArguments, FunctionDeclaration, FunctionExpression, Identifier, ImportDeclaration, InterfaceDeclaration, MethodDeclaration, ModuleDeclaration, Node, NodeFactory, ParseConfigHost, PropertyAccessExpression, QualifiedName, Statement, TransformationContext, TypeAliasDeclaration, TypeChecker, TypeParameterDeclaration, TypeReferenceNode } from 'typescript';

import { ReflectionOp } from '@deepkit/type-spec';
import { Resolver } from './resolver.js';
import { ReflectionMode, reflectionModes, Resolver } from './resolver.js';
export declare function isObject(obj: any): obj is {

@@ -17,3 +17,2 @@ [key: string]: any;

export declare const packSize: number;
declare const reflectionModes: readonly ["always", "default", "never"];
interface ReflectionOptions {

@@ -125,3 +124,3 @@ /**

*/
protected compileDeclarations: Map<InterfaceDeclaration | TypeAliasDeclaration | EnumDeclaration, {
protected compileDeclarations: Map<TypeAliasDeclaration | InterfaceDeclaration | EnumDeclaration, {
name: EntityName;

@@ -172,3 +171,5 @@ sourceFile: SourceFile;

transformSourceFile(sourceFile: SourceFile): SourceFile;
protected injectResetΩ<T extends FunctionDeclaration | FunctionExpression | MethodDeclaration | ConstructorDeclaration>(node: T): T;
protected getModuleType(): 'cjs' | 'esm';
protected getArrowFunctionΩPropertyAccessIdentifier(node: ArrowFunction): Identifier;
protected injectResetΩ<T extends FunctionDeclaration | FunctionExpression | MethodDeclaration | ConstructorDeclaration | ArrowFunction>(node: T): T;
protected createProgramVarFromNode(node: Node, name: EntityName, sourceFile: SourceFile): Statement[];

@@ -281,3 +282,3 @@ protected extractPackStructOfType(node: Node | Declaration | ClassDeclaration | ClassExpression, program: CompilerProgram): void;

*/
protected decorateFunctionExpression(expression: FunctionExpression): FunctionExpression | ts.CallExpression;
protected decorateFunctionExpression(expression: FunctionExpression): ts.CallExpression | FunctionExpression;
/**

@@ -288,8 +289,8 @@ * function name() {}

*/
protected decorateFunctionDeclaration(declaration: FunctionDeclaration): FunctionDeclaration | ts.ExportAssignment | Statement[] | undefined;
protected decorateFunctionDeclaration(declaration: FunctionDeclaration): Statement[] | FunctionDeclaration | ts.ExportAssignment | undefined;
/**
* const fn = () => { }
* => const fn = Object.assign(() => {}, {__type: 34})
* const fn = () => {}
* => const fn = __assignType(() => {}, [34])
*/
protected decorateArrow(expression: ArrowFunction): ArrowFunction | ts.CallExpression;
protected decorateArrowFunction(expression: ArrowFunction): ts.CallExpression | ArrowFunction;
/**

@@ -303,3 +304,3 @@ * Object.assign(fn, {__type: []}) is much slower than a custom implementation like

protected wrapWithAssignType(fn: Expression, type: Expression): ts.CallExpression;
protected parseReflectionMode(mode: typeof reflectionModes[number] | '' | boolean | string | string[] | undefined, configPathDir: string): typeof reflectionModes[number];
protected parseReflectionMode(mode: ReflectionMode, configPathDir: string): typeof reflectionModes[number];
protected resolvedTsConfig: {

@@ -306,0 +307,0 @@ [path: string]: {

import type { CompilerHost, CompilerOptions, ExportDeclaration, ImportDeclaration, ResolvedModule, SourceFile } from 'typescript';
export declare const reflectionModes: readonly ["always", "default", "never"];
export type ReflectionMode = typeof reflectionModes[number] | '' | boolean | string | string[] | undefined;
export declare function patternMatch(path: string, patterns: string[], base?: string): boolean;
export declare function reflectionModeMatcher(filePath: string, mode: ReflectionMode, configPathDir?: string): typeof reflectionModes[number];
/**

@@ -3,0 +7,0 @@ * A utility to resolve a module path and its declaration.

import ts from 'typescript';
import * as micromatch from 'micromatch';
import { isAbsolute } from 'path';
const { createSourceFile, resolveModuleName, SyntaxKind, ScriptTarget, } = ts;
export const reflectionModes = ['always', 'default', 'never'];
export function patternMatch(path, patterns, base) {
const normalized = patterns.map(v => {
if (v[0] === '!') {
if (!isAbsolute(v.slice(1)))
return `!${base}/${v.substr(1)}`;
return v;
}
if (!isAbsolute(v))
return `${base}/${v}`;
return v;
});
const matched = micromatch.default([path], normalized, {});
return matched.length > 0;
}
export function reflectionModeMatcher(filePath, mode, configPathDir) {
if (Array.isArray(mode)) {
if (!configPathDir)
return 'never';
return patternMatch(filePath, mode, configPathDir) ? 'default' : 'never';
}
if ('boolean' === typeof mode)
return mode ? 'default' : 'never';
if (mode === 'default' || mode === 'always')
return mode;
return 'never';
}
/**

@@ -4,0 +33,0 @@ * A utility to resolve a module path and its declaration.

@@ -15,2 +15,3 @@ /*

export * from './src/compiler.js';
export * from './src/plugin.js';
export * from './src/loader.js';

@@ -17,0 +18,0 @@

{
"name": "@deepkit/type-compiler",
"version": "1.0.1-alpha.108",
"version": "1.0.1-alpha.109",
"description": "Deepkit/type compiler/Typescript transformer",

@@ -17,3 +17,4 @@ "type": "commonjs",

"bin": {
"deepkit-type-install": "./deepkit-type-install.js"
"deepkit-type-install": "./deepkit-type-install.js",
"deepkit-compiler-debug": "./deepkit-compiler-debug.js"
},

@@ -41,3 +42,3 @@ "sideEffects": false,

"@marcj/ts-clone-node": "^2.0.0",
"@typescript/vfs": "^1.4.0",
"@typescript/vfs": "1.5.0",
"get-tsconfig": "^4.5.0",

@@ -65,3 +66,3 @@ "lz-string": "^1.4.4",

},
"gitHead": "7f207009f9c18138e924521629c41ef56e4474a6"
"gitHead": "d69fa25227af0d601ea7ff0f903b91ac29f17470"
}

@@ -1,12 +0,5 @@

import type {
CompilerHost,
CompilerOptions,
ExportDeclaration,
Expression,
ImportDeclaration,
ResolvedModule,
SourceFile,
StringLiteral,
} from 'typescript';
import type { CompilerHost, CompilerOptions, ExportDeclaration, Expression, ImportDeclaration, ResolvedModule, SourceFile, StringLiteral, } from 'typescript';
import ts from 'typescript';
import * as micromatch from 'micromatch';
import { isAbsolute } from 'path';

@@ -20,2 +13,34 @@ const {

export const reflectionModes = ['always', 'default', 'never'] as const;
export type ReflectionMode = typeof reflectionModes[number] | '' | boolean | string | string[] | undefined;
export function patternMatch(path: string, patterns: string[], base?: string) {
const normalized = patterns.map(v => {
if (v[0] === '!') {
if (!isAbsolute(v.slice(1))) return `!${base}/${v.substr(1)}`;
return v;
}
if (!isAbsolute(v)) return `${base}/${v}`;
return v;
})
const matched = micromatch.default([path], normalized, {});
return matched.length > 0;
}
export function reflectionModeMatcher(
filePath: string,
mode: ReflectionMode,
configPathDir?: string
): typeof reflectionModes[number] {
if (Array.isArray(mode)) {
if (!configPathDir) return 'never';
return patternMatch(filePath, mode, configPathDir) ? 'default' : 'never';
}
if ('boolean' === typeof mode) return mode ? 'default' : 'never';
if (mode === 'default' || mode === 'always') return mode;
return 'never';
}
/**

@@ -22,0 +47,0 @@ * A utility to resolve a module path and its declaration.

@@ -26,2 +26,3 @@ {

"install-transformer.ts",
"compiler-debug.ts",
"index.ts"

@@ -28,0 +29,0 @@ ],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc