npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

anycop

v0.2.4

Published

This is a tool to visualize any inferences included in the project code.

Downloads

22

Readme

anycop👮‍♂️

This is a tool to visualize "any" inferences included in the TypeScript project code. Any type comes even if you don't want to. No matter how careful you are, once some library has been delivered, it cannot be prevented. Also, you may get lost in the code when you were in a hurry temporarily.

Take advantage of this tool to keep type safe code from getting lost or compromised. Once the situation is visualized, you can understand the problem and share it with the team. It would be great if You had time to work on improving the type safety coverage.

Any is not ruffian. Without TypeScript this specification would have been impossible to apply static typing to the current JavaScript ecosystem. Build better relationships with "any" with this tool.

What will this do?👮‍♀️

When executed in the current directory of a TypeScript project, "any" inferred parts will be reported. The file path and kind found are logged. Then, the totals to be inspected and the type safety coverage are reported.

VScode is great, and if you run it with the built-in command line tool, you can jump to the corresponding location by pressing the output file path.

$ npm i -D anycop
$ anycop
/~/anycop/src/checkers.ts:45:12 👮‍♂️ < VariableDeclaration
/~/anycop/src/log.ts:9:9 👮‍♂️ < VariableDeclaration
/~/anycop/src/log.ts:9:17 👮‍♂️ < AsExpression
┌──────────────────────┬────────────┬──────────┬────────────────────┐
│                      │ CheckCount │ AnyCount │ TypeSafe Coverage  │
├──────────────────────┼────────────┼──────────┼────────────────────┤
│ VariableDeclaration  │ 45         │ 2        │ 0.9555555555555556 │
├──────────────────────┼────────────┼──────────┼────────────────────┤
│ ParameterDeclaration │ 42         │ 0        │ 1                  │
├──────────────────────┼────────────┼──────────┼────────────────────┤
│ BindingElement       │ 8          │ 0        │ 1                  │
├──────────────────────┼────────────┼──────────┼────────────────────┤
│ FunctionDeclReturn   │ 9          │ 0        │ 1                  │
├──────────────────────┼────────────┼──────────┼────────────────────┤
│ ArrowFunctionReturn  │ 13         │ 0        │ 1                  │
├──────────────────────┼────────────┼──────────┼────────────────────┤
│ AsExpression         │ 3          │ 1        │ 0.6666666666666667 │
├──────────────────────┼────────────┼──────────┼────────────────────┤
│ Total                │ 120        │ 3        │ 0.975              │
└──────────────────────┴────────────┴──────────┴────────────────────┘

How far it be detected?🚨

With the power of the TypeScript CompilerAPI, it can detect "any" inferences that are not mentioned in the code.

VariableDeclaration

Detects "any" inferences as well as explicit any annotations on variables.

function greet(message: any) {
  return message
}
// inferred "any" at VariableDeclaration
const message = greet('hello')

ParameterDeclaration

It detects not only the explicit annotation of the argument but also the case where the type definition referred to is equivalent to "any".

// annotation of "any" at ParameterDeclaration (message)
function greet(message: any) {
  return message
}

BindingElement

Detects when a reference expanded by an object is inferred by "any".

type Props = { a: any, b: any }
// inferred "any" at BindingElement (a & b)
function greet({ a, b }: Props) {
  return { a, b }
}

FunctionDeclReturn

It detects return types that have become "any", as well as explicit return type "any" annotations.

// inferred "any" at FunctionDeclReturn
function greet() {
  const message: any = 'hello'
  return message
}

ArrowFunctionReturn

It detects return types that have become "any", as well as explicit return type "any" annotations.

// inferred "any" at ArrowFunctionReturn
const abc = (param: string) => {
  switch (param) {
    case 'a':
      return true
    case 'b':
      return false
    case 'c':
      return '' as any
  }
}

AsExpression

Detect assertions by "as" keywords.

function greet() {
  return 'hello' as any // at AsExpression
}

anycop.config.js

By setting anycop.config.js in the project root, unique settings can be made. errorThrethold is the error reporting threshold.

If the total of "TypeSafe Coverage" falls below this value, an error can be generated. Please use it for introduction to integration tools.

// anycop.config.js
module.exports = {
  targetDir: ".",
  errorThrethold: 0.2
}