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

ts-poet

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-poet - npm Package Compare versions

Comparing version 6.8.2 to 6.9.0

33

build/Import.js

@@ -214,3 +214,4 @@ "use strict";

toImportPiece() {
return this.sourceSymbol ? `${this.sourceSymbol} as ${this.symbol}` : this.symbol;
const maybeTypePrefix = this.typeImport ? "type " : "";
return maybeTypePrefix + (this.sourceSymbol ? `${this.sourceSymbol} as ${this.symbol}` : this.symbol);
}

@@ -278,22 +279,17 @@ }

// Partition named imported into `import type` vs. regular imports
const allNames = filterInstances(imports, ImportsName);
const names = unique(allNames.filter((i) => !i.typeImport).map((it) => it.toImportPiece()));
const def = unique(filterInstances(imports, ImportsDefault).map((it) => it.symbol));
if (forceRequireImports.includes(modulePath) && def.length > 0) {
result += `import ${def[0]} = require('${importPath}');\n`;
const symbolImports = filterInstancesAnd(imports, ImportsName, (it) => !it.typeImport);
const typeImports = filterInstancesAnd(imports, ImportsName, (it) => {
return !!it.typeImport && !symbolImports.some((s) => s.symbol === it.symbol);
});
const namedImports = unique([...typeImports, ...symbolImports].map((it) => it.toImportPiece()));
const defaultImports = unique(filterInstances(imports, ImportsDefault).map((it) => it.symbol));
if (forceRequireImports.includes(modulePath) && defaultImports.length > 0) {
result += `import ${defaultImports[0]} = require('${importPath}');\n`;
}
else if (names.length > 0 || def.length > 0) {
else if (namedImports.length > 0 || defaultImports.length > 0) {
// Output named imports as a group
const namesPart = names.length > 0 ? [`{ ${names.join(", ")} }`] : [];
const defPart = def.length > 0 ? [def[0]] : [];
const namesPart = namedImports.length > 0 ? [`{ ${namedImports.join(", ")} }`] : [];
const defPart = defaultImports.length > 0 ? [defaultImports[0]] : [];
result += `import ${[...defPart, ...namesPart].join(", ")} from '${importPath}';\n`;
}
const typeImports = unique(allNames
.filter((i) => i.typeImport)
.map((it) => it.toImportPiece())
// If the `import type` is already used as a concrete import, just use that
.filter((p) => !names.includes(p)));
if (typeImports.length > 0) {
result += `import type { ${typeImports.join(", ")} } from '${importPath}';\n`;
}
});

@@ -308,2 +304,5 @@ const sideEffectImports = (0, utils_1.groupBy)(filterInstances(imports, SideEffect), (a) => a.source);

}
function filterInstancesAnd(list, t, fn) {
return list.filter((e) => e instanceof t && fn(e));
}
function unique(list) {

@@ -310,0 +309,0 @@ return [...new Set(list)];

{
"name": "ts-poet",
"version": "6.8.2",
"version": "6.9.0",
"description": "code generation DSL for TypeScript",

@@ -5,0 +5,0 @@ "main": "build/index.js",

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