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

type-coverage

Package Overview
Dependencies
Maintainers
1
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-coverage - npm Package Compare versions

Comparing version 1.12.0 to 1.13.0

21

dist/checker.js

@@ -146,2 +146,6 @@ "use strict";

case typescript_1.default.SyntaxKind.Identifier:
const id = node;
if (context.catchVariables[id.escapedText]) {
return;
}
collectData(node, context);

@@ -837,4 +841,17 @@ break;

const catchClause = node;
checkNode(catchClause.variableDeclaration, context);
checkNode(catchClause.block, context);
if (context.ignoreCatch) {
const copyContext = Object.assign({}, context);
copyContext.catchVariables = Object.assign({}, context.catchVariables);
if (catchClause.variableDeclaration) {
const decl = catchClause.variableDeclaration;
if (decl.name.kind === typescript_1.default.SyntaxKind.Identifier) {
copyContext.catchVariables[decl.name.escapedText] = true;
}
}
checkNode(catchClause.variableDeclaration, copyContext);
}
else {
checkNode(catchClause.block, context);
checkNode(catchClause.variableDeclaration, context);
}
break;

@@ -841,0 +858,0 @@ case typescript_1.default.SyntaxKind.PropertyAssignment:

2

dist/core.d.ts
import ts from 'typescript';
import { AnyInfo } from './interfaces';
export declare function lint(project: string, detail: boolean, debug: boolean, files?: string[], oldProgram?: ts.Program, strict?: boolean, enableCache?: boolean): Promise<{
export declare function lint(project: string, detail: boolean, debug: boolean, files?: string[], oldProgram?: ts.Program, strict?: boolean, enableCache?: boolean, ignoreCatch?: boolean): Promise<{
correctCount: number;

@@ -5,0 +5,0 @@ totalCount: number;

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

// tslint:disable-next-line:no-big-function cognitive-complexity
async function lint(project, detail, debug, files, oldProgram, strict = false, enableCache = false) {
async function lint(project, detail, debug, files, oldProgram, strict = false, enableCache = false, ignoreCatch = false) {
const { configFilePath, dirname } = tsconfig_1.getTsConfigFilePath(project);

@@ -68,2 +68,4 @@ const config = tsconfig_1.getTsConfig(configFilePath, dirname);

},
ignoreCatch,
catchVariables: {},
debug,

@@ -70,0 +72,0 @@ detail,

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

suppressError = argv.suppressError;
const { correctCount, totalCount, anys } = await core_1.lint(argv.p || argv.project || '.', true, argv.debug, undefined, undefined, argv.strict, argv.cache);
const { correctCount, totalCount, anys } = await core_1.lint(argv.p || argv.project || '.', true, argv.debug, undefined, undefined, argv.strict, argv.cache, argv['ignore-catch']);
const percent = Math.round(10000 * correctCount / totalCount) / 100;

@@ -28,0 +28,0 @@ const atLeast = await getAtLeast(argv);

@@ -23,2 +23,6 @@ import ts from 'typescript';

checker: ts.TypeChecker;
ignoreCatch: boolean;
catchVariables: {
[variable: string]: boolean;
};
ingoreMap: {

@@ -25,0 +29,0 @@ [file: string]: Set<number>;

{
"name": "type-coverage",
"version": "1.12.0",
"version": "1.13.0",
"description": "A CLI tool to check type coverage for typescript code",

@@ -16,11 +16,11 @@ "main": "dist/core.js",

"@types/minimist": "1.2.0",
"@types/node": "11.11.6",
"@types/node": "11.13.4",
"clean-release": "2.7.0",
"clean-scripts": "1.9.2",
"jasmine": "3.3.1",
"markdownlint-cli": "0.14.0",
"jasmine": "3.4.0",
"markdownlint-cli": "0.15.0",
"no-unused-export": "1.7.0",
"rimraf": "2.6.3",
"standard": "12.0.1",
"tslint": "5.14.0",
"tslint": "5.15.0",
"tslint-config-standard": "8.0.1",

@@ -27,0 +27,0 @@ "tslint-sonarts": "1.9.0"

@@ -32,2 +32,3 @@ # type-coverage

`--strict` | boolean? | [strict mode](#strict-mode)
`--ignore-catch` | boolean? | [ignore catch](#ignore-catch)
`--cache` | boolean? | [enable cache](#enable-cache)

@@ -45,2 +46,22 @@

### ignore catch
If you want to get 100% type coverage then `try {} catch {}` is
the largest blocked towards that.
This can be fixed in typescript with [Allow type annotation on catch clause variable](https://github.com/Microsoft/TypeScript/issues/20024)
but until then you can turn on `--ignore-catch --at-least 100`.
Your catch blocks should look like
```ts
try {
await ...
} catch (anyErr) {
const err = <Error> anyErr
}
```
To have the highest type coverage.
## config in package.json

@@ -87,3 +108,4 @@

strict = false,
enableCache = false
enableCache = false,
ignoreCatch = false
): Promise<{

@@ -90,0 +112,0 @@ correctCount: number

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