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

ts-transformer-keys

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-transformer-keys - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

8

package.json
{
"name": "ts-transformer-keys",
"version": "0.4.0",
"version": "0.4.1",
"description": "A TypeScript custom transformer which enables to obtain keys of given type.",

@@ -29,5 +29,5 @@ "scripts": {

"@types/mocha": "^5.2.7",
"@types/node": "^12.7.1",
"mocha": "^6.2.0",
"typescript": "^3.6.4"
"@types/node": "^12.12.12",
"mocha": "^6.2.2",
"typescript": "^3.7.2"
},

@@ -34,0 +34,0 @@ "peerDependencies": {

@@ -71,2 +71,3 @@ # ts-transformer-keys

// rollup.config.js
import resolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';

@@ -78,2 +79,3 @@ import keysTransformer from 'ts-transformer-keys/transformer';

plugins: [
resolve(),
typescript({ transformers: [service => ({

@@ -85,3 +87,2 @@ before: [ keysTransformer(service.getProgram()) ],

};
```

@@ -88,0 +89,0 @@

@@ -14,2 +14,5 @@ "use strict";

var typeChecker = program.getTypeChecker();
if (isKeysImportExpression(node)) {
return;
}
if (!isKeysCallExpression(node, typeChecker)) {

@@ -25,2 +28,17 @@ return node;

}
var indexJs = path.join(__dirname, 'index.js');
function isKeysImportExpression(node) {
if (!ts.isImportDeclaration(node)) {
return false;
}
var module = node.moduleSpecifier.text;
try {
return indexJs === (module.startsWith('.')
? require.resolve(path.resolve(path.dirname(node.getSourceFile().fileName), module))
: require.resolve(module));
}
catch (e) {
return false;
}
}
var indexTs = path.join(__dirname, 'index.d.ts');

@@ -27,0 +45,0 @@ function isKeysCallExpression(node, typeChecker) {

@@ -9,9 +9,14 @@ import * as ts from 'typescript';

function visitNodeAndChildren(node: ts.SourceFile, program: ts.Program, context: ts.TransformationContext): ts.SourceFile;
function visitNodeAndChildren(node: ts.Node, program: ts.Program, context: ts.TransformationContext): ts.Node;
function visitNodeAndChildren(node: ts.Node, program: ts.Program, context: ts.TransformationContext): ts.Node {
function visitNodeAndChildren(node: ts.Node, program: ts.Program, context: ts.TransformationContext): ts.Node | undefined;
function visitNodeAndChildren(node: ts.Node, program: ts.Program, context: ts.TransformationContext): ts.Node | undefined {
return ts.visitEachChild(visitNode(node, program), childNode => visitNodeAndChildren(childNode, program, context), context);
}
function visitNode(node: ts.Node, program: ts.Program): ts.Node {
function visitNode(node: ts.SourceFile, program: ts.Program): ts.SourceFile;
function visitNode(node: ts.Node, program: ts.Program): ts.Node | undefined;
function visitNode(node: ts.Node, program: ts.Program): ts.Node | undefined {
const typeChecker = program.getTypeChecker();
if (isKeysImportExpression(node)) {
return;
}
if (!isKeysCallExpression(node, typeChecker)) {

@@ -28,2 +33,19 @@ return node;

const indexJs = path.join(__dirname, 'index.js');
function isKeysImportExpression(node: ts.Node): node is ts.ImportDeclaration {
if (!ts.isImportDeclaration(node)) {
return false;
}
const module = (node.moduleSpecifier as ts.StringLiteral).text;
try {
return indexJs === (
module.startsWith('.')
? require.resolve(path.resolve(path.dirname(node.getSourceFile().fileName), module))
: require.resolve(module)
);
} catch(e) {
return false;
}
}
const indexTs = path.join(__dirname, 'index.d.ts');

@@ -30,0 +52,0 @@ function isKeysCallExpression(node: ts.Node, typeChecker: ts.TypeChecker): node is ts.CallExpression {

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