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 4.11.0 to 4.12.0

4

build/Code.d.ts

@@ -15,2 +15,6 @@ import { Node } from './Node';

prettierOverrides?: Options;
/** optional importMappings */
importMappings?: {
[key: string]: string;
};
}

@@ -17,0 +21,0 @@ export declare class Code extends Node {

4

build/Code.js

@@ -52,3 +52,3 @@ "use strict";

toStringWithImports(opts) {
const { path = '', forceDefaultImport, forceModuleImport, prefix, prettierOverrides = {} } = opts || {};
const { path = '', forceDefaultImport, forceModuleImport, prefix, prettierOverrides = {}, importMappings = {} } = opts || {};
const ourModulePath = path.replace(/\.[tj]sx?/, '');

@@ -62,3 +62,3 @@ if (forceDefaultImport || forceModuleImport) {

assignAliasesIfNeeded(defs, imports, ourModulePath);
const importPart = Import_1.emitImports(imports, ourModulePath);
const importPart = Import_1.emitImports(imports, ourModulePath, importMappings);
const bodyPart = this.generateCode();

@@ -65,0 +65,0 @@ const maybePrefix = prefix ? `${prefix}\n` : '';

@@ -74,3 +74,3 @@ import { Node } from './Node';

*/
static importsName(exportedName: string, from: string, typeImport: boolean): Import;
static importsName(exportedName: string, from: string, typeImport: boolean, sourceExportedName?: string): Import;
/**

@@ -186,5 +186,7 @@ * Creates a symbol that is brought in by a whole module import

/** Generates the `import ...` lines for the given `imports`. */
export declare function emitImports(imports: Import[], ourModulePath: string): string;
export declare function emitImports(imports: Import[], ourModulePath: string, importMappings: {
[key: string]: string;
}): string;
export declare function maybeRelativePath(outputPath: string, importPath: string): string;
/** Checks if `path1 === path2` despite minor path differences like `./foo` and `foo`. */
export declare function sameModule(path1: string, path2: string): boolean;

@@ -16,2 +16,4 @@ "use strict";

const importPattern = `^(${typeImportMarker}${identPattern})?(${exports.importType})(${modulePattern})(?:#(${identPattern}))?`;
const sourceIdentPattern = `(?:(?:${identPattern}:)?)`;
const sourceImportPattern = `^(${typeImportMarker}${sourceIdentPattern}${identPattern})?(@)(${modulePattern})(?:#(${identPattern}))?`;
/**

@@ -59,3 +61,6 @@ * Specifies a symbol and its related origin, either via import or implicit/local declaration.

static from(spec) {
const matched = spec.match(importPattern);
let matched = spec.match(importPattern);
if (matched === null) {
matched = spec.match(sourceImportPattern);
}
if (matched != null) {

@@ -70,8 +75,13 @@ const modulePath = matched[3];

case '@':
if (symbolName.startsWith('t:')) {
return Import.importsName(symbolName.substring(2), modulePath, true);
const isTypeImport = symbolName.startsWith('t:');
let exportedNames;
if (isTypeImport) {
exportedNames = symbolName.substring(2).split(':');
}
else {
return Import.importsName(symbolName, modulePath, false);
exportedNames = symbolName.split(':');
}
const exportedName = exportedNames.pop();
const sourceExportedName = exportedNames[0];
return Import.importsName(exportedName, modulePath, isTypeImport, sourceExportedName);
case '=':

@@ -120,4 +130,4 @@ return Import.importsDefault(symbolName, modulePath);

*/
static importsName(exportedName, from, typeImport) {
return new ImportsName(exportedName, from, undefined, typeImport);
static importsName(exportedName, from, typeImport, sourceExportedName) {
return new ImportsName(exportedName, from, sourceExportedName, typeImport);
}

@@ -266,3 +276,3 @@ /**

/** Generates the `import ...` lines for the given `imports`. */
function emitImports(imports, ourModulePath) {
function emitImports(imports, ourModulePath, importMappings) {
if (imports.length == 0) {

@@ -283,2 +293,5 @@ return '';

}
if (modulePath in importMappings) {
modulePath = importMappings[modulePath];
}
const importPath = maybeRelativePath(ourModulePath, modulePath);

@@ -285,0 +298,0 @@ // Output star imports individually

{
"name": "ts-poet",
"version": "4.11.0",
"version": "4.12.0",
"description": "code generation DSL for TypeScript",

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

@@ -77,3 +77,5 @@ ![npm](https://img.shields.io/npm/v/ts-poet)

* `imp("Observable@rxjs")` --> `import { Observable } from "rxjs"`
* `imp("Observable:CustomizedObservable@rxjs")` --> `import { Observable as CustomizedObservable } from "rxjs"`
* `imp("t:Observable@rxjs")` --> `import type { Observable } from "rxjs"`
* `imp("t:Observable:CustomizedObservable@rxjs")` --> `import type { Observable as CustomizedObservable } from "rxjs"`
* `imp("Observable@./Api")` --> `import { Observable } from "./Api"`

@@ -80,0 +82,0 @@ * `imp("Observable*./Api")` --> `import * as Observable from "./Api"`

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