type-coverage-core
Advanced tools
Comparing version 2.12.0 to 2.13.0
@@ -6,3 +6,3 @@ "use strict"; | ||
const typescript_1 = tslib_1.__importDefault(require("typescript")); | ||
function collectAny(node, context) { | ||
function collectAny(node, context, kind) { | ||
const { file, sourceFile, typeCheckResult, ingoreMap, debug, processAny } = context; | ||
@@ -17,6 +17,6 @@ if (processAny !== undefined) { | ||
if (debug) { | ||
console.log(`type === any: ${file}:${line + 1}:${character + 1}: ${node.getText(sourceFile)}`); | ||
console.log(`type === any(${kind}): ${file}:${line + 1}:${character + 1}: ${node.getText(sourceFile)}`); | ||
} | ||
else { | ||
typeCheckResult.anys.push({ line, character, text: node.getText(sourceFile) }); | ||
typeCheckResult.anys.push({ line, character, text: node.getText(sourceFile), kind }); | ||
} | ||
@@ -45,3 +45,4 @@ return true; | ||
if (types.every((t) => typeIsStrictAny(t, context.strict))) { | ||
const success = collectAny(node, context); | ||
const kind = types.every((t) => typeIsStrictAny(t, false)) ? 1 /* any */ : 2 /* containsAny */; | ||
const success = collectAny(node, context, kind); | ||
if (!success) { | ||
@@ -76,3 +77,3 @@ collectNotAny(node, context, type); | ||
} | ||
function checkTypeAssertion(node, context) { | ||
function checkTypeAssertion(node, context, kind) { | ||
if (context.strict) { | ||
@@ -95,3 +96,3 @@ if ((typescript_1.default.isAsExpression(node) || typescript_1.default.isTypeAssertion(node))) { | ||
} | ||
const success = collectAny(node, context); | ||
const success = collectAny(node, context, kind); | ||
if (success) { | ||
@@ -310,3 +311,3 @@ context.typeCheckResult.totalCount++; | ||
if (typescript_1.default.isTypeAssertion(node)) { | ||
checkTypeAssertion(node, context); | ||
checkTypeAssertion(node, context, 4 /* unsafeTypeAssertion */); | ||
checkNode(node.expression, context); | ||
@@ -372,3 +373,3 @@ checkNode(node.type, context); | ||
if (typescript_1.default.isAsExpression(node)) { | ||
checkTypeAssertion(node, context); | ||
checkTypeAssertion(node, context, 3 /* unsafeAs */); | ||
checkNode(node.expression, context); | ||
@@ -379,3 +380,3 @@ checkNode(node.type, context); | ||
if (typescript_1.default.isNonNullExpression(node)) { | ||
checkTypeAssertion(node, context); | ||
checkTypeAssertion(node, context, 5 /* unsafeNonNull */); | ||
checkNode(node.expression, context); | ||
@@ -382,0 +383,0 @@ return; |
@@ -13,7 +13,18 @@ import ts from 'typescript'; | ||
} | ||
interface FileAnyInfo { | ||
/** | ||
* @public | ||
*/ | ||
export interface FileAnyInfo { | ||
line: number; | ||
character: number; | ||
text: string; | ||
kind: FileAnyInfoKind; | ||
} | ||
export declare const enum FileAnyInfoKind { | ||
any = 1, | ||
containsAny = 2, | ||
unsafeAs = 3, | ||
unsafeTypeAssertion = 4, | ||
unsafeNonNull = 5 | ||
} | ||
/** | ||
@@ -20,0 +31,0 @@ * @public |
{ | ||
"name": "type-coverage-core", | ||
"version": "2.12.0", | ||
"version": "2.13.0", | ||
"description": "A library to check type coverage for typescript code", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.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
49887
1258