New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ts-unused-exports

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-unused-exports - npm Package Compare versions

Comparing version 2.0.8 to 2.0.9

spec/data/import-e.ts

32

lib/parser.js

@@ -41,2 +41,8 @@ "use strict";

};
var extractExportStatement = function (decl) {
return decl.exportClause
? decl.exportClause.elements
.map(function (e) { return (e.propertyName || e.name).text; })
: [];
};
var extractExportFromImport = function (decl) {

@@ -122,14 +128,20 @@ var moduleSpecifier = decl.moduleSpecifier, exportClause = decl.exportClause;

if (kind === ts.SyntaxKind.ExportDeclaration) {
var fw = extractExportFromImport(node);
var key = addImport(fw);
if (key) {
var what = fw.what;
if (what == star) {
exports.push("*:" + key);
if (node.moduleSpecifier === undefined) {
exports.push.apply(exports, extractExportStatement(node));
return;
}
else {
var fw = extractExportFromImport(node);
var key = addImport(fw);
if (key) {
var what = fw.what;
if (what == star) {
exports.push("*:" + key);
}
else {
exports = exports.concat(what);
}
}
else {
exports = exports.concat(what);
}
return;
}
return;
}

@@ -136,0 +148,0 @@ if (hasModifier(node, ts.SyntaxKind.ExportKeyword)) {

{
"name": "ts-unused-exports",
"version": "2.0.8",
"version": "2.0.9",
"description": "ts-unused-exports finds unused exported symbols in your Typescript project",

@@ -5,0 +5,0 @@ "main": "lib/app.js",

@@ -12,3 +12,3 @@ const { join } = require('path');

const analysis = app(join(__dirname, 'data/tsconfig-single-file.json'));
expect(analysis.exports).toEqual([ 'b', 'c', 'd', 'default' ]);
expect(analysis.exports).toEqual([ 'b', 'c', 'd', 'e', 'default' ]);
});

@@ -18,5 +18,5 @@

const analysis = app(join(__dirname, 'data/tsconfig-include.json'));
expect(analysis.exports).toEqual([ 'b', 'c', 'd', 'default' ]);
expect(analysis.exports).toEqual([ 'b', 'c', 'd', 'e', 'default' ]);
});
});

@@ -9,2 +9,6 @@ export class a {}; // tslint:disable-line

const e = () => 5;
export { e };
export default 4;

@@ -9,2 +9,6 @@ export class a {}; // tslint:disable-line

const e = () => 5;
export { e };
export default 4;

@@ -18,12 +18,13 @@ const { join } = require('path');

itIs('nothing', [] , [ 'a', 'b', 'c', 'd', 'default' ]);
itIs('default', ['./import-default.ts'] , [ 'a', 'b', 'c', 'd' ]);
itIs('a' , ['./import-a.ts'] , [ 'b', 'c', 'd', 'default' ]);
itIs('b' , ['./import-b.ts'] , [ 'a', 'c', 'd', 'default' ]);
itIs('c' , ['./import-c.ts'] , [ 'a', 'b', 'd', 'default' ]);
itIs('d' , ['./import-d.ts'] , [ 'a', 'b', 'c', 'default' ]);
itIs('nothing', [] , [ 'a', 'b', 'c', 'd', 'e', 'default' ]);
itIs('default', ['./import-default.ts'] , [ 'a', 'b', 'c', 'd', 'e' ]);
itIs('a' , ['./import-a.ts'] , [ 'b', 'c', 'd', 'e', 'default' ]);
itIs('b' , ['./import-b.ts'] , [ 'a', 'c', 'd', 'e', 'default' ]);
itIs('c' , ['./import-c.ts'] , [ 'a', 'b', 'd', 'e', 'default' ]);
itIs('d' , ['./import-d.ts'] , [ 'a', 'b', 'c', 'e', 'default' ]);
itIs('e' , ['./import-e.ts'] , [ 'a', 'b', 'c', 'd', 'default' ]);
itIs('*' , ['./import-star.ts'] , [ 'default' ]);
itIs('all' , ['./import-star.ts'
,'./import-default.ts'], undefined);
itIs('non-ts' , ['./import-other.ts'] , [ 'b', 'c', 'd', 'default' ]);
itIs('non-ts' , ['./import-other.ts'] , [ 'b', 'c', 'd', 'e', 'default' ]);

@@ -34,3 +35,3 @@ it('handles export * from', () => {

expect(result['exports']).toEqual(['default']);
expect(result['import-export-star']).toEqual([ 'a', 'b', 'c', 'd' ]);
expect(result['import-export-star']).toEqual([ 'a', 'b', 'c', 'd', 'e' ]);
});

@@ -112,9 +113,9 @@

['./import-a-with-base-url.ts'],
['b', 'c', 'd', 'default']
['b', 'c', 'd', 'e', 'default']
);
itIs('default',
['./import-default-with-base-url.ts'],
['a', 'b', 'c', 'd']
['a', 'b', 'c', 'd', 'e']
);
});
});

@@ -52,2 +52,9 @@ import { existsSync, readFileSync } from 'fs';

const extractExportStatement = (decl:ts.ExportDeclaration): string[] => {
return decl.exportClause
? decl.exportClause.elements
.map(e => (e.propertyName || e.name).text)
: [];
};
const extractExportFromImport = (decl:ts.ExportDeclaration) : FromWhat => {

@@ -144,13 +151,18 @@ const { moduleSpecifier, exportClause } = decl;

if (kind === ts.SyntaxKind.ExportDeclaration) {
const fw = extractExportFromImport(node as ts.ExportDeclaration);
const key = addImport(fw);
if (key) {
const { what } = fw;
if (what == star) {
exports.push(`*:${key}`);
} else {
exports = exports.concat(what);
if ((node as ts.ExportDeclaration).moduleSpecifier === undefined) {
exports.push(...extractExportStatement(node as ts.ExportDeclaration));
return;
} else {
const fw = extractExportFromImport(node as ts.ExportDeclaration);
const key = addImport(fw);
if (key) {
const { what } = fw;
if (what == star) {
exports.push(`*:${key}`);
} else {
exports = exports.concat(what);
}
}
return;
}
return;
}

@@ -157,0 +169,0 @@

Sorry, the diff of this file is not supported yet

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