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

dts-bundle-generator

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dts-bundle-generator - npm Package Compare versions

Comparing version 7.2.0 to 8.0.0

2

config-schema.d.ts

@@ -1,2 +0,2 @@

// Generated by dts-bundle-generator v7.2.0
// Generated by dts-bundle-generator v8.0.0

@@ -3,0 +3,0 @@ export interface CompilationOptions {

@@ -1,2 +0,2 @@

// Generated by dts-bundle-generator v7.2.0
// Generated by dts-bundle-generator v8.0.0

@@ -3,0 +3,0 @@ export interface CompilationOptions {

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

const typesUsageEvaluator = new types_usage_evaluator_1.TypesUsageEvaluator(sourceFiles, typeChecker);
let uniqueNameCounter = 1;
return entries.map((entry) => {

@@ -49,10 +50,22 @@ (0, logger_1.normalLog)(`Processing ${entry.filePath}`);

renamedExports: [],
declarationsRenaming: new Map(),
};
const outputOptions = entry.output || {};
const inlineDeclareGlobals = Boolean(outputOptions.inlineDeclareGlobals);
const needStripDefaultKeywordForStatement = (statement) => {
const statementExports = (0, typescript_1.getExportsForStatement)(rootFileExports, typeChecker, statement);
// a statement should have a 'default' keyword only if it it declared in the root source file
// otherwise it will be re-exported via `export { name as default }`
const defaultExport = statementExports.find((exp) => exp.exportedName === 'default');
return {
needStrip: defaultExport === undefined || defaultExport.originalName !== 'default' && statement.getSourceFile() !== rootSourceFile,
newName: (0, typescript_1.isNodeNamedDeclaration)(statement) ? collectionResult.declarationsRenaming.get(statement) : undefined,
};
};
const updateResultCommonParams = {
isStatementUsed: (statement) => isNodeUsed(statement, rootFileExportSymbols, typesUsageEvaluator, typeChecker),
isStatementUsed: (statement) => isNodeUsed(statement, rootFileExportSymbols, typesUsageEvaluator, typeChecker, criteria, inlineDeclareGlobals),
shouldStatementBeImported: (statement) => {
return shouldNodeBeImported(statement, rootFileExportSymbols, typesUsageEvaluator, typeChecker, program.isSourceFileDefaultLibrary.bind(program), criteria);
return shouldNodeBeImported(statement, rootFileExportSymbols, typesUsageEvaluator, typeChecker, program.isSourceFileDefaultLibrary.bind(program), criteria, inlineDeclareGlobals);
},
shouldDeclareGlobalBeInlined: (currentModule) => Boolean(outputOptions.inlineDeclareGlobals) && currentModule.type === 0 /* ModuleType.ShouldBeInlined */,
shouldDeclareGlobalBeInlined: (currentModule) => inlineDeclareGlobals && currentModule.type === 0 /* ModuleType.ShouldBeInlined */,
shouldDeclareExternalModuleBeInlined: () => Boolean(outputOptions.inlineDeclareExternals),

@@ -65,3 +78,22 @@ getModuleInfo: (fileNameOrModuleLike) => {

},
resolveIdentifier: (identifier) => (0, typescript_1.resolveIdentifier)(typeChecker, identifier),
resolveIdentifier: (identifier) => {
const resolvedDeclaration = (0, typescript_1.resolveIdentifier)(typeChecker, identifier);
if (resolvedDeclaration === undefined) {
return undefined;
}
const storedValue = collectionResult.declarationsRenaming.get(resolvedDeclaration);
if (storedValue !== undefined) {
return storedValue;
}
let identifierName = resolvedDeclaration.name?.getText();
if ((0, typescript_1.hasNodeModifier)(resolvedDeclaration, ts.SyntaxKind.DefaultKeyword)
&& resolvedDeclaration.name === undefined
&& needStripDefaultKeywordForStatement(resolvedDeclaration).needStrip) {
// this means that a node is default-exported from its module but from entry point it is exported with a different name(s)
// so we have to generate some random name and then re-export it with really exported names
identifierName = `__DTS_BUNDLE_GENERATOR__GENERATED_NAME$${uniqueNameCounter++}`;
collectionResult.declarationsRenaming.set(resolvedDeclaration, identifierName);
}
return identifierName;
},
getDeclarationsForExportedAssignment: (exportAssignment) => {

@@ -76,3 +108,3 @@ const symbolForExpression = typeChecker.getSymbolAtLocation(exportAssignment.expression);

getDeclarationUsagesSourceFiles: (declaration) => {
return getDeclarationUsagesSourceFiles(declaration, rootFileExportSymbols, typesUsageEvaluator, typeChecker, criteria);
return getDeclarationUsagesSourceFiles(declaration, rootFileExportSymbols, typesUsageEvaluator, typeChecker, criteria, inlineDeclareGlobals);
},

@@ -86,3 +118,3 @@ areDeclarationSame: (left, right) => {

let moduleName;
if (ts.isExportDeclaration(node)) {
if (ts.isExportDeclaration(node) || ts.isImportDeclaration(node)) {
moduleName = node.moduleSpecifier;

@@ -93,2 +125,7 @@ }

}
else if (ts.isImportEqualsDeclaration(node)) {
if (ts.isExternalModuleReference(node.moduleReference)) {
moduleName = node.moduleReference.expression;
}
}
else if (ts.isLiteralTypeNode(node.argument) && ts.isStringLiteral(node.argument.literal)) {

@@ -144,9 +181,3 @@ moduleName = node.argument.literal;

...collectionResult,
needStripDefaultKeywordForStatement: (statement) => {
const statementExports = (0, typescript_1.getExportsForStatement)(rootFileExports, typeChecker, statement);
// a statement should have a 'default' keyword only if it it declared in the root source file
// otherwise it will be re-exported via `export { name as default }`
const defaultExport = statementExports.find((exp) => exp.exportedName === 'default');
return defaultExport === undefined || defaultExport.originalName !== 'default' && statement.getSourceFile() !== rootSourceFile;
},
needStripDefaultKeywordForStatement,
shouldStatementHasExportKeyword: (statement) => {

@@ -158,3 +189,3 @@ const statementExports = (0, typescript_1.getExportsForStatement)(rootFileExports, typeChecker, statement);

// to put export keyword for this statement because we'll re-export it in the way
const hasStatementedDefaultKeyword = (0, typescript_1.hasNodeModifier)(statement, ts.SyntaxKind.DefaultKeyword);
const hasStatementDefaultKeyword = (0, typescript_1.hasNodeModifier)(statement, ts.SyntaxKind.DefaultKeyword);
let result = statementExports.length === 0 || statementExports.find((exp) => {

@@ -165,3 +196,3 @@ // "directly" means "without renaming" or "without additional node/statement"

// so we shouldn't add this either
const shouldBeDefaultExportedDirectly = exp.exportedName === 'default' && hasStatementedDefaultKeyword && statement.getSourceFile() === rootSourceFile;
const shouldBeDefaultExportedDirectly = exp.exportedName === 'default' && hasStatementDefaultKeyword && statement.getSourceFile() === rootSourceFile;
return shouldBeDefaultExportedDirectly || exp.exportedName === exp.originalName;

@@ -177,3 +208,4 @@ }) !== undefined;

|| ts.isFunctionDeclaration(statement)
|| ts.isVariableStatement(statement);
|| ts.isVariableStatement(statement)
|| ts.isModuleDeclaration(statement);
if (onlyDirectlyExportedShouldBeExported) {

@@ -291,7 +323,6 @@ // "valuable" statements must be re-exported from root source file

}
const exportedNameNode = params.resolveIdentifier(statement.expression);
if (exportedNameNode === undefined) {
const originalName = params.resolveIdentifier(statement.expression);
if (originalName === undefined) {
continue;
}
const originalName = exportedNameNode.getText();
result.renamedExports.push(`${originalName} as default`);

@@ -303,7 +334,6 @@ continue;

for (const exportItem of statement.exportClause.elements) {
const exportedNameNode = params.resolveIdentifier(exportItem.name);
if (exportedNameNode === undefined) {
const originalName = params.resolveIdentifier(exportItem.name);
if (originalName === undefined) {
continue;
}
const originalName = exportedNameNode.getText();
const exportedName = exportItem.name.getText();

@@ -334,2 +364,12 @@ if (originalName !== exportedName) {

}
function getReferencedModuleInfo(moduleDecl, params) {
const referencedModule = params.resolveReferencedModule(moduleDecl);
if (referencedModule === null) {
return null;
}
const moduleFilePath = ts.isSourceFile(referencedModule)
? referencedModule.fileName
: resolveModuleFileName(referencedModule.getSourceFile().fileName, referencedModule.name.text);
return params.getModuleInfo(moduleFilePath);
}
function updateResultForModuleDeclaration(moduleDecl, params, result) {

@@ -341,18 +381,11 @@ if (moduleDecl.body === undefined || !ts.isModuleBlock(moduleDecl.body)) {

if (!ts.isStringLiteral(moduleDecl.name)) {
// this is an old behavior of handling `declare module Name` statements
// where Name is a identifier, not a string literal
// actually in this case I'd say we need to add a statement as-is without processing
// but it might be a breaking change to let's not break it yet
const moduleFileName = resolveModuleFileName(params.currentModule.fileName, moduleDecl.name.text);
moduleInfo = params.getModuleInfo(moduleFileName);
result.statements.push(moduleDecl);
return;
}
else {
const referencedModule = params.resolveReferencedModule(moduleDecl);
if (referencedModule === null) {
const referencedModuleInfo = getReferencedModuleInfo(moduleDecl, params);
if (referencedModuleInfo === null) {
return;
}
const moduleFilePath = ts.isSourceFile(referencedModule)
? referencedModule.fileName
: resolveModuleFileName(referencedModule.getSourceFile().fileName, referencedModule.name.text);
moduleInfo = params.getModuleInfo(moduleFilePath);
moduleInfo = referencedModuleInfo;
}

@@ -414,4 +447,4 @@ // if we have declaration of external module inside internal one

}
function getDeclarationUsagesSourceFiles(declaration, rootFileExports, typesUsageEvaluator, typeChecker, criteria) {
return new Set(getExportedSymbolsUsingStatement(declaration, rootFileExports, typesUsageEvaluator, typeChecker, criteria)
function getDeclarationUsagesSourceFiles(declaration, rootFileExports, typesUsageEvaluator, typeChecker, criteria, withGlobals) {
return new Set(getExportedSymbolsUsingStatement(declaration, rootFileExports, typesUsageEvaluator, typeChecker, criteria, withGlobals)
.map((symbol) => (0, typescript_1.getDeclarationsForSymbol)(symbol))

@@ -439,10 +472,10 @@ .reduce((acc, val) => acc.concat(val), [])

function addImport(statement, params, imports) {
if (statement.name === undefined) {
if (!ts.isSourceFile(statement) && statement.name === undefined) {
throw new Error(`Import/usage unnamed declaration: ${statement.getText()}`);
}
params.getDeclarationUsagesSourceFiles(statement).forEach((sourceFile) => {
const statements = ts.isSourceFile(sourceFile)
const sourceFileStatements = ts.isSourceFile(sourceFile)
? sourceFile.statements
: sourceFile.body.statements;
statements.forEach((st) => {
sourceFileStatements.forEach((st) => {
if (!ts.isImportEqualsDeclaration(st) && !ts.isImportDeclaration(st)) {

@@ -455,2 +488,7 @@ return;

}
const referencedModuleInfo = getReferencedModuleInfo(st, params);
// if a referenced module should be inlined we can just ignore it
if (referencedModuleInfo === null || referencedModuleInfo.type !== 1 /* ModuleType.ShouldBeImported */) {
return;
}
let importItem = imports.get(importModuleSpecifier);

@@ -509,4 +547,16 @@ if (importItem === undefined) {

}
function isNodeUsed(node, rootFileExports, typesUsageEvaluator, typeChecker) {
if ((0, typescript_1.isNodeNamedDeclaration)(node)) {
function getGlobalSymbolsUsingSymbol(symbol, typesUsageEvaluator, criteria) {
return Array.from(typesUsageEvaluator.getSymbolsUsingSymbol(symbol) ?? []).filter((usedInSymbol) => {
if (usedInSymbol.escapedName !== ts.InternalSymbolName.Global) {
return false;
}
return (0, typescript_1.getDeclarationsForSymbol)(usedInSymbol).some((decl) => {
const closestModuleLike = getClosestModuleLikeNode(decl);
const moduleInfo = getModuleLikeInfo(closestModuleLike, criteria);
return moduleInfo.type === 0 /* ModuleType.ShouldBeInlined */;
});
});
}
function isNodeUsed(node, rootFileExports, typesUsageEvaluator, typeChecker, criteria, withGlobals) {
if ((0, typescript_1.isNodeNamedDeclaration)(node) || ts.isSourceFile(node)) {
const nodeSymbol = getNodeSymbol(node, typeChecker);

@@ -516,7 +566,11 @@ if (nodeSymbol === null) {

}
return rootFileExports.some((rootExport) => typesUsageEvaluator.isSymbolUsedBySymbol(nodeSymbol, rootExport));
const nodeUsedByDirectExports = rootFileExports.some((rootExport) => typesUsageEvaluator.isSymbolUsedBySymbol(nodeSymbol, rootExport));
if (nodeUsedByDirectExports) {
return true;
}
return withGlobals && getGlobalSymbolsUsingSymbol(nodeSymbol, typesUsageEvaluator, criteria).length !== 0;
}
else if (ts.isVariableStatement(node)) {
return node.declarationList.declarations.some((declaration) => {
return isNodeUsed(declaration, rootFileExports, typesUsageEvaluator, typeChecker);
return isNodeUsed(declaration, rootFileExports, typesUsageEvaluator, typeChecker, criteria, withGlobals);
});

@@ -526,3 +580,4 @@ }

}
function shouldNodeBeImported(node, rootFileExports, typesUsageEvaluator, typeChecker, isDefaultLibrary, criteria) {
// eslint-disable-next-line max-params
function shouldNodeBeImported(node, rootFileExports, typesUsageEvaluator, typeChecker, isDefaultLibrary, criteria, withGlobals) {
const nodeSymbol = getNodeSymbol(node, typeChecker);

@@ -548,5 +603,5 @@ if (nodeSymbol === null) {

}
return getExportedSymbolsUsingStatement(node, rootFileExports, typesUsageEvaluator, typeChecker, criteria).length !== 0;
return getExportedSymbolsUsingStatement(node, rootFileExports, typesUsageEvaluator, typeChecker, criteria, withGlobals).length !== 0;
}
function getExportedSymbolsUsingStatement(node, rootFileExports, typesUsageEvaluator, typeChecker, criteria) {
function getExportedSymbolsUsingStatement(node, rootFileExports, typesUsageEvaluator, typeChecker, criteria, withGlobals) {
const nodeSymbol = getNodeSymbol(node, typeChecker);

@@ -560,15 +615,27 @@ if (nodeSymbol === null) {

}
// we should import only symbols which are used in types directly
return Array.from(symbolsUsingNode).filter((symbol) => {
const symbolsDeclarations = (0, typescript_1.getDeclarationsForSymbol)(symbol);
if (symbolsDeclarations.length === 0 || symbolsDeclarations.every((decl) => {
// we need to make sure that at least 1 declaration is inlined
return getModuleLikeInfo(getClosestModuleLikeNode(decl), criteria).type !== 0 /* ModuleType.ShouldBeInlined */;
})) {
return false;
}
return rootFileExports.some((rootSymbol) => typesUsageEvaluator.isSymbolUsedBySymbol(symbol, rootSymbol));
});
return [
// symbols which are used in types directly
...Array.from(symbolsUsingNode).filter((symbol) => {
const symbolsDeclarations = (0, typescript_1.getDeclarationsForSymbol)(symbol);
if (symbolsDeclarations.length === 0 || symbolsDeclarations.every((decl) => {
// we need to make sure that at least 1 declaration is inlined
return getModuleLikeInfo(getClosestModuleLikeNode(decl), criteria).type !== 0 /* ModuleType.ShouldBeInlined */;
})) {
return false;
}
return rootFileExports.some((rootSymbol) => typesUsageEvaluator.isSymbolUsedBySymbol(symbol, rootSymbol));
}),
// symbols which are used in global types i.e. in `declare global`s
...(withGlobals ? getGlobalSymbolsUsingSymbol(nodeSymbol, typesUsageEvaluator, criteria) : []),
];
}
function getNodeSymbol(node, typeChecker) {
if (ts.isSourceFile(node)) {
const fileSymbol = typeChecker.getSymbolAtLocation(node);
// a source file might not have a symbol in case of no exports in that file
if (fileSymbol === undefined) {
return null;
}
return (0, typescript_1.getActualSymbol)(fileSymbol, typeChecker);
}
const nodeName = (0, typescript_1.getNodeName)(node);

@@ -575,0 +642,0 @@ if (nodeName === undefined) {

@@ -29,5 +29,5 @@ "use strict";

}
host.resolveModuleNames = (moduleNames, containingFile) => {
return moduleNames.map((moduleName) => {
const resolvedModule = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host).resolvedModule;
host.resolveModuleNameLiterals = (moduleLiterals, containingFile) => {
return moduleLiterals.map((moduleLiteral) => {
const resolvedModule = ts.resolveModuleName(moduleLiteral.text, containingFile, compilerOptions, host).resolvedModule;
if (resolvedModule && !resolvedModule.isExternalLibraryImport && resolvedModule.extension !== ts.Extension.Dts) {

@@ -38,3 +38,3 @@ resolvedModule.extension = ts.Extension.Dts;

}
return resolvedModule;
return { resolvedModule };
});

@@ -41,0 +41,0 @@ };

"use strict";
// tslint:disable:strict-type-predicates
Object.defineProperty(exports, "__esModule", { value: true });

@@ -4,0 +3,0 @@ exports.checkSchemaMatch = exports.schemaPrimitiveValues = void 0;

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

const shouldStatementHasExportKeyword = helpers.shouldStatementHasExportKeyword(statement);
const needStripDefaultKeyword = helpers.needStripDefaultKeywordForStatement(statement);
const printer = ts.createPrinter({

@@ -93,9 +92,14 @@ newLine: ts.NewLineKind.LineFeed,

}
let newName;
// strip the `default` keyword from node
if (modifiersMap[ts.SyntaxKind.DefaultKeyword] && needStripDefaultKeyword) {
// we need just to remove `default` from any node except class node
// for classes we need to replace `default` with `declare` instead
modifiersMap[ts.SyntaxKind.DefaultKeyword] = false;
if (ts.isClassDeclaration(node)) {
modifiersMap[ts.SyntaxKind.DeclareKeyword] = true;
if (modifiersMap[ts.SyntaxKind.DefaultKeyword]) {
const needStripDefaultKeywordResult = helpers.needStripDefaultKeywordForStatement(statement);
if (needStripDefaultKeywordResult.needStrip) {
// we need just to remove `default` from any node except class node
// for classes we need to replace `default` with `declare` instead
modifiersMap[ts.SyntaxKind.DefaultKeyword] = false;
if (ts.isClassDeclaration(node)) {
modifiersMap[ts.SyntaxKind.DeclareKeyword] = true;
}
newName = needStripDefaultKeywordResult.newName;
}

@@ -116,6 +120,7 @@ }

|| ts.isVariableStatement(node)
|| ts.isEnumDeclaration(node))) {
|| ts.isEnumDeclaration(node)
|| ts.isModuleDeclaration(node))) {
modifiersMap[ts.SyntaxKind.DeclareKeyword] = true;
}
return (0, typescript_1.recreateRootLevelNodeWithModifiers)(node, modifiersMap, shouldStatementHasExportKeyword);
return (0, typescript_1.recreateRootLevelNodeWithModifiers)(node, modifiersMap, newName, shouldStatementHasExportKeyword);
},

@@ -122,0 +127,0 @@ });

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

const resolvedIdentifier = resolveIdentifierBySymbol(exp.symbol);
exp.originalName = resolvedIdentifier !== undefined ? resolvedIdentifier.getText() : exp.symbol.escapedName;
exp.originalName = resolvedIdentifier?.name !== undefined ? resolvedIdentifier.name.getText() : exp.symbol.escapedName;
});

@@ -192,3 +192,3 @@ return result;

}
return decl.name;
return decl;
}

@@ -261,4 +261,4 @@ function getExportsForStatement(exportedSymbols, typeChecker, statement) {

exports.modifiersMapToArray = modifiersMapToArray;
function recreateRootLevelNodeWithModifiers(node, modifiersMap, keepComments = true) {
const newNode = recreateRootLevelNodeWithModifiersImpl(node, modifiersMap);
function recreateRootLevelNodeWithModifiers(node, modifiersMap, newName, keepComments = true) {
const newNode = recreateRootLevelNodeWithModifiersImpl(node, modifiersMap, newName);
if (keepComments) {

@@ -270,16 +270,4 @@ ts.setCommentRange(newNode, ts.getCommentRange(node));

exports.recreateRootLevelNodeWithModifiers = recreateRootLevelNodeWithModifiers;
function prependEmptyDecoratorsIfNeeded(func, ...args) {
const tsVersion = parseFloat(ts.versionMajorMinor);
if (tsVersion < 4.8) {
// decorators don't exist in the declaration files anyway so we can ignore them
return func([], ...args);
}
else {
// just pass args as is in
// eslint-disable-next-line prefer-spread
return func.apply(null, args);
}
}
// eslint-disable-next-line complexity
function recreateRootLevelNodeWithModifiersImpl(node, modifiersMap) {
function recreateRootLevelNodeWithModifiersImpl(node, modifiersMap, newName) {
const modifiers = modifiersMapToArray(modifiersMap);

@@ -290,58 +278,36 @@ if (ts.isArrowFunction(node)) {

if (ts.isClassDeclaration(node)) {
return prependEmptyDecoratorsIfNeeded(
// eslint-disable-next-line deprecation/deprecation
ts.factory.createClassDeclaration, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members);
return ts.factory.createClassDeclaration(modifiers, newName || node.name, node.typeParameters, node.heritageClauses, node.members);
}
if (ts.isClassExpression(node)) {
return prependEmptyDecoratorsIfNeeded(
// eslint-disable-next-line deprecation/deprecation
ts.factory.createClassExpression, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members);
return ts.factory.createClassExpression(modifiers, newName || node.name, node.typeParameters, node.heritageClauses, node.members);
}
if (ts.isEnumDeclaration(node)) {
return prependEmptyDecoratorsIfNeeded(
// eslint-disable-next-line deprecation/deprecation
ts.factory.createEnumDeclaration, modifiers, node.name, node.members);
return ts.factory.createEnumDeclaration(modifiers, newName || node.name, node.members);
}
if (ts.isExportAssignment(node)) {
return prependEmptyDecoratorsIfNeeded(
// eslint-disable-next-line deprecation/deprecation
ts.factory.createExportAssignment, modifiers, node.isExportEquals, node.expression);
return ts.factory.createExportAssignment(modifiers, node.isExportEquals, node.expression);
}
if (ts.isExportDeclaration(node)) {
return prependEmptyDecoratorsIfNeeded(
// eslint-disable-next-line deprecation/deprecation
ts.factory.createExportDeclaration, modifiers, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause);
return ts.factory.createExportDeclaration(modifiers, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause);
}
if (ts.isFunctionDeclaration(node)) {
return prependEmptyDecoratorsIfNeeded(
// eslint-disable-next-line deprecation/deprecation
ts.factory.createFunctionDeclaration, modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body);
return ts.factory.createFunctionDeclaration(modifiers, node.asteriskToken, newName || node.name, node.typeParameters, node.parameters, node.type, node.body);
}
if (ts.isFunctionExpression(node)) {
return ts.factory.createFunctionExpression(modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body);
return ts.factory.createFunctionExpression(modifiers, node.asteriskToken, newName || node.name, node.typeParameters, node.parameters, node.type, node.body);
}
if (ts.isImportDeclaration(node)) {
return prependEmptyDecoratorsIfNeeded(
// eslint-disable-next-line deprecation/deprecation
ts.factory.createImportDeclaration, modifiers, node.importClause, node.moduleSpecifier, node.assertClause);
return ts.factory.createImportDeclaration(modifiers, node.importClause, node.moduleSpecifier, node.assertClause);
}
if (ts.isImportEqualsDeclaration(node)) {
return prependEmptyDecoratorsIfNeeded(
// eslint-disable-next-line deprecation/deprecation
ts.factory.createImportEqualsDeclaration, modifiers, node.isTypeOnly, node.name, node.moduleReference);
return ts.factory.createImportEqualsDeclaration(modifiers, node.isTypeOnly, newName || node.name, node.moduleReference);
}
if (ts.isInterfaceDeclaration(node)) {
return prependEmptyDecoratorsIfNeeded(
// eslint-disable-next-line deprecation/deprecation
ts.factory.createInterfaceDeclaration, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members);
return ts.factory.createInterfaceDeclaration(modifiers, newName || node.name, node.typeParameters, node.heritageClauses, node.members);
}
if (ts.isModuleDeclaration(node)) {
return prependEmptyDecoratorsIfNeeded(
// eslint-disable-next-line deprecation/deprecation
ts.factory.createModuleDeclaration, modifiers, node.name, node.body, node.flags);
return ts.factory.createModuleDeclaration(modifiers, node.name, node.body, node.flags);
}
if (ts.isTypeAliasDeclaration(node)) {
return prependEmptyDecoratorsIfNeeded(
// eslint-disable-next-line deprecation/deprecation
ts.factory.createTypeAliasDeclaration, modifiers, node.name, node.typeParameters, node.type);
return ts.factory.createTypeAliasDeclaration(modifiers, newName || node.name, node.typeParameters, node.type);
}

@@ -354,17 +320,8 @@ if (ts.isVariableStatement(node)) {

}
function canHaveModifiersCompat(node) {
const compatTs = ts;
return compatTs.canHaveModifiers !== undefined ? compatTs.canHaveModifiers(node) : true;
}
function getModifiersCompat(node) {
const compatTs = ts;
// eslint-disable-next-line deprecation/deprecation
return compatTs.getModifiers !== undefined ? compatTs.getModifiers(node) : node.modifiers;
}
function getModifiers(node) {
if (!canHaveModifiersCompat(node)) {
throw new Error(`Node kind=${ts.SyntaxKind[node.kind]} cannot have modifiers`);
if (!ts.canHaveModifiers(node)) {
return undefined;
}
return getModifiersCompat(node);
return ts.getModifiers(node);
}
exports.getModifiers = getModifiers;

@@ -49,7 +49,7 @@ "use strict";

}
else if ((0, typescript_1.isNodeNamedDeclaration)(node) && node.name) {
if ((0, typescript_1.isNodeNamedDeclaration)(node) && node.name) {
const childSymbol = this.getSymbol(node.name);
this.computeUsagesRecursively(node, childSymbol);
}
else if (ts.isVariableStatement(node)) {
if (ts.isVariableStatement(node)) {
for (const varDeclaration of node.declarationList.declarations) {

@@ -63,4 +63,3 @@ this.computeUsageForNode(varDeclaration);

for (const child of queue) {
// eslint-disable-next-line deprecation/deprecation
if (child.kind === ts.SyntaxKind.JSDocComment) {
if (child.kind === ts.SyntaxKind.JSDoc) {
continue;

@@ -67,0 +66,0 @@ }

{
"name": "dts-bundle-generator",
"version": "7.2.0",
"version": "8.0.0",
"description": "DTS Bundle Generator",

@@ -19,3 +19,3 @@ "main": "dist/bundle-generator.js",

"dependencies": {
"typescript": ">=4.5.2",
"typescript": ">=5.0.2",
"yargs": "^17.6.0"

@@ -22,0 +22,0 @@ },

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