type-coverage
Advanced tools
Comparing version 1.7.0 to 1.8.0
@@ -8,3 +8,3 @@ "use strict"; | ||
// tslint:disable-next-line:no-big-function | ||
async function lint(project, detail, debug, files, oldProgram, strict) { | ||
async function lint(project, detail, debug, files, oldProgram, strict = false) { | ||
const { configFilePath, dirname } = tsconfig_1.getTsConfigFilePath(project); | ||
@@ -42,14 +42,5 @@ const config = tsconfig_1.getTsConfig(configFilePath, dirname); | ||
totalCount++; | ||
if (typeIsAny(type)) { | ||
if (typeIsStrictAny(type, strict)) { | ||
collectAny(node, file, sourceFile); | ||
} | ||
else if (strict && type.flags === typescript_1.default.TypeFlags.Object) { | ||
const typeArguments = type.typeArguments; | ||
if (typeArguments && typeArguments.some((ypeArgument) => typeIsAny(ypeArgument))) { | ||
collectAny(node, file, sourceFile); | ||
} | ||
else { | ||
collectNotAny(node, file, sourceFile, type); | ||
} | ||
} | ||
else { | ||
@@ -79,2 +70,3 @@ collectNotAny(node, file, sourceFile, type); | ||
handleNodes(node.modifiers, file, sourceFile); | ||
// tslint:disable-next-line:max-switch-cases | ||
switch (node.kind) { | ||
@@ -911,4 +903,13 @@ case typescript_1.default.SyntaxKind.Unknown: | ||
exports.lint = lint; | ||
function typeIsAny(type) { | ||
return type.flags === 1 && type.intrinsicName === 'any'; | ||
function typeIsStrictAny(type, strict) { | ||
if (type.flags === typescript_1.default.TypeFlags.Any) { | ||
return type.intrinsicName === 'any'; | ||
} | ||
if (strict && type.flags === typescript_1.default.TypeFlags.Object) { | ||
const typeArguments = type.typeArguments; | ||
if (typeArguments) { | ||
return typeArguments.some((typeArgument) => typeIsStrictAny(typeArgument, strict)); | ||
} | ||
} | ||
return false; | ||
} |
{ | ||
"name": "type-coverage", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"description": "A CLI tool to check type coverage for typescript code", | ||
@@ -14,3 +14,3 @@ "main": "dist/core.js", | ||
"@types/glob": "7.1.1", | ||
"@types/jasmine": "3.3.7", | ||
"@types/jasmine": "3.3.8", | ||
"@types/minimist": "1.2.0", | ||
@@ -27,3 +27,3 @@ "@types/node": "10.12.18", | ||
"tslint-config-standard": "8.0.1", | ||
"tslint-sonarts": "1.8.0" | ||
"tslint-sonarts": "1.9.0" | ||
}, | ||
@@ -30,0 +30,0 @@ "dependencies": { |
@@ -31,3 +31,3 @@ # type-coverage | ||
--debug | boolean? | show debug info | ||
--strict | boolean? | if the identifiers' type arguments exist and contain at least one `any`, like `any[]`, `ReadonlyArray<any>`, `Promise<any>`, `Foo<number, any>`, is will considered as `any` too; also, future minor release may introduce stricter type check in this mode, which may lower the code coverage | ||
--strict | boolean? | if the identifiers' type arguments exist and contain at least one `any`, like `any[]`, `ReadonlyArray<any>`, `Promise<any>`, `Foo<number, any>`, it will be considered as `any` too; also, future minor release may introduce stricter type check in this mode, which may lower the code coverage | ||
@@ -34,0 +34,0 @@ ## config in package.json |
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
1105
64824