parse-imports-ts
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -51,2 +51,20 @@ "use strict"; | ||
} | ||
function parseTsNamedImports(importClause) { | ||
var type = types_1.ImportedPackageType.TypeImport; | ||
typescript_1.default.forEachChild(importClause, function (child) { | ||
if (typescript_1.default.isImportSpecifier(child) && !child.isTypeOnly) { | ||
type = types_1.ImportedPackageType.NormalImport; | ||
} | ||
}); | ||
return type; | ||
} | ||
function parseTsImportClause(importClause) { | ||
var type = types_1.ImportedPackageType.NormalImport; | ||
typescript_1.default.forEachChild(importClause, function (child) { | ||
if (typescript_1.default.isNamedImports(child)) { | ||
type = parseTsNamedImports(child); | ||
} | ||
}); | ||
return type; | ||
} | ||
function parseTsImportDeclaration(importDeclaration) { | ||
@@ -60,2 +78,5 @@ var result = []; | ||
} | ||
else { | ||
type = parseTsImportClause(child); | ||
} | ||
} | ||
@@ -62,0 +83,0 @@ if (typescript_1.default.isStringLiteral(child)) { |
@@ -8,3 +8,3 @@ "use strict"; | ||
ImportedPackageType[ImportedPackageType["TypeImport"] = 1] = "TypeImport"; | ||
})(ImportedPackageType = exports.ImportedPackageType || (exports.ImportedPackageType = {})); | ||
})(ImportedPackageType || (exports.ImportedPackageType = ImportedPackageType = {})); | ||
//# sourceMappingURL=types.js.map |
@@ -45,2 +45,20 @@ var __read = (this && this.__read) || function (o, n) { | ||
} | ||
function parseTsNamedImports(importClause) { | ||
var type = ImportedPackageType.TypeImport; | ||
ts.forEachChild(importClause, function (child) { | ||
if (ts.isImportSpecifier(child) && !child.isTypeOnly) { | ||
type = ImportedPackageType.NormalImport; | ||
} | ||
}); | ||
return type; | ||
} | ||
function parseTsImportClause(importClause) { | ||
var type = ImportedPackageType.NormalImport; | ||
ts.forEachChild(importClause, function (child) { | ||
if (ts.isNamedImports(child)) { | ||
type = parseTsNamedImports(child); | ||
} | ||
}); | ||
return type; | ||
} | ||
function parseTsImportDeclaration(importDeclaration) { | ||
@@ -54,2 +72,5 @@ var result = []; | ||
} | ||
else { | ||
type = parseTsImportClause(child); | ||
} | ||
} | ||
@@ -56,0 +77,0 @@ if (ts.isStringLiteral(child)) { |
@@ -5,3 +5,3 @@ export declare enum ImportedPackageType { | ||
} | ||
export declare type ImportedPackage = { | ||
export type ImportedPackage = { | ||
name: string; | ||
@@ -8,0 +8,0 @@ type: ImportedPackageType; |
{ | ||
"name": "parse-imports-ts", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"repository": { | ||
@@ -41,7 +41,7 @@ "type": "git", | ||
"ts-node": "^10.7.0", | ||
"typescript": "^4.5.5" | ||
"typescript": "^5.3.3" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^4.5.5" | ||
"typescript": "^5" | ||
} | ||
} |
@@ -24,2 +24,26 @@ /* eslint-disable @typescript-eslint/no-use-before-define */ | ||
function parseTsNamedImports( | ||
importClause: ts.Node, | ||
): ImportedPackageType { | ||
let type = ImportedPackageType.TypeImport; | ||
ts.forEachChild(importClause, (child: ts.Node) => { | ||
if (ts.isImportSpecifier(child) && !child.isTypeOnly) { | ||
type = ImportedPackageType.NormalImport; | ||
} | ||
}); | ||
return type; | ||
} | ||
function parseTsImportClause( | ||
importClause: ts.Node, | ||
): ImportedPackageType { | ||
let type = ImportedPackageType.NormalImport; | ||
ts.forEachChild(importClause, (child: ts.Node) => { | ||
if (ts.isNamedImports(child)) { | ||
type = parseTsNamedImports(child); | ||
} | ||
}); | ||
return type; | ||
} | ||
function parseTsImportDeclaration( | ||
@@ -34,2 +58,4 @@ importDeclaration: ts.Node, | ||
type = ImportedPackageType.TypeImport; | ||
} else { | ||
type = parseTsImportClause(child); | ||
} | ||
@@ -36,0 +62,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
48520
772
43