dts-bundle-generator
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -125,3 +125,3 @@ #!/usr/bin/env node | ||
} | ||
else if (args.verbose) { // tslint:disable-line:unnecessary-else | ||
else if (args.verbose) { | ||
logger_1.enableVerbose(); | ||
@@ -128,0 +128,0 @@ } |
@@ -96,3 +96,6 @@ "use strict"; | ||
var result = true; | ||
if (ts.isClassDeclaration(statement) || ts.isEnumDeclaration(statement) || ts.isFunctionDeclaration(statement)) { | ||
if (ts.isClassDeclaration(statement) | ||
|| ts.isEnumDeclaration(statement) | ||
|| ts.isFunctionDeclaration(statement) | ||
|| ts.isVariableStatement(statement)) { | ||
var isStatementFromRootFile = statement.getSourceFile() === rootSourceFile; | ||
@@ -274,3 +277,3 @@ var exportType = typescript_1.getExportTypeForDeclaration(rootFileExports, typeChecker, statement); | ||
} | ||
else if (ts.isVariableStatement(node)) { // tslint:disable-line:unnecessary-else | ||
else if (ts.isVariableStatement(node)) { | ||
return node.declarationList.declarations.some(function (declaration) { | ||
@@ -277,0 +280,0 @@ return isNodeUsed(declaration, rootFileExports, typesUsageEvaluator, typeChecker); |
@@ -49,3 +49,3 @@ "use strict"; | ||
} | ||
else if (a.text < b.text) { // tslint:disable-line:unnecessary-else | ||
else if (a.text < b.text) { | ||
return -1; | ||
@@ -96,3 +96,3 @@ } | ||
} | ||
else if (isNodeExported && !shouldNodeBeExported) { // tslint:disable-line:unnecessary-else | ||
else if (isNodeExported && !shouldNodeBeExported) { | ||
return nodeText.slice('export '.length); | ||
@@ -99,0 +99,0 @@ } |
@@ -124,6 +124,31 @@ "use strict"; | ||
function getExportTypeForDeclaration(exportedSymbols, typeChecker, declaration) { | ||
if (declaration.name === undefined) { | ||
if (ts.isVariableStatement(declaration)) { | ||
if (declaration.declarationList.declarations.length === 0) { | ||
return null; | ||
} | ||
var firstDeclarationExportType_1 = getExportTypeForName(exportedSymbols, typeChecker, declaration.declarationList.declarations[0].name); | ||
var allDeclarationsHaveSameExportType = declaration.declarationList.declarations.every(function (variableDecl) { | ||
// all declaration should have the same export type | ||
// TODO: for now it's not supported to have different type of exports | ||
return getExportTypeForName(exportedSymbols, typeChecker, variableDecl.name) === firstDeclarationExportType_1; | ||
}); | ||
if (!allDeclarationsHaveSameExportType) { | ||
// log warn? | ||
return null; | ||
} | ||
return firstDeclarationExportType_1; | ||
} | ||
return getExportTypeForName(exportedSymbols, typeChecker, declaration.name); | ||
} | ||
exports.getExportTypeForDeclaration = getExportTypeForDeclaration; | ||
function getExportTypeForName(exportedSymbols, typeChecker, name) { | ||
if (name === undefined) { | ||
return null; | ||
} | ||
var declarationSymbol = typeChecker.getSymbolAtLocation(declaration.name); | ||
if (ts.isArrayBindingPattern(name) || ts.isObjectBindingPattern(name)) { | ||
// TODO: binding patterns in variable declarations are not supported for now | ||
// see https://github.com/microsoft/TypeScript/issues/30598 also | ||
return null; | ||
} | ||
var declarationSymbol = typeChecker.getSymbolAtLocation(name); | ||
var exportedSymbol = exportedSymbols.find(function (rootExport) { return rootExport.symbol === declarationSymbol; }); | ||
@@ -135,2 +160,1 @@ if (exportedSymbol === undefined) { | ||
} | ||
exports.getExportTypeForDeclaration = getExportTypeForDeclaration; |
@@ -37,6 +37,6 @@ "use strict"; | ||
// print red | ||
console.error("\u001B[31m" + message + "\u001B[0m"); | ||
console.error("\u001B[0;31m" + message + "\u001B[0m"); | ||
break; | ||
case 2 /* Warning */: | ||
console.warn(message); | ||
console.warn("\u001B[1;33m" + message + "\u001B[0m"); | ||
break; | ||
@@ -43,0 +43,0 @@ case 1 /* Normal */: |
{ | ||
"name": "dts-bundle-generator", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "DTS Bundle Generator", | ||
@@ -5,0 +5,0 @@ "main": "bundle-generator.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75453
1461