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

@definitelytyped/dts-critic

Package Overview
Dependencies
Maintainers
7
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@definitelytyped/dts-critic

Checks a new .d.ts against the Javascript source and tells you what problems it has

  • 0.0.112-next.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
47K
increased by2.91%
Maintainers
7
Weekly downloads
 
Created
Source

dts-critic

Checks a new dts against the Javascript sources and tells you what problems it has.

Usage

Build the program:

$ npm run build

Run the program using node:

$ node dist/index.js --dts=path-to-d.ts [--js=path-to-source] [--mode=mode] [--debug]

If the d.ts path is to a file named index.d.ts, the name of the directory will be used as the package name instead. For example ~/dt/types/jquery/index.d.ts will use jquery as the name.

path-to-source is optional; if you leave it off, the code will check npm for a package with the same name as the d.ts.

Mode

You can run dts-critic in different modes that affect which checks will be performed:

  1. name-only: dts-critic will check your package name and [DefinitelyTyped header] (https://github.com/Microsoft/definitelytyped-header-parser) (if present) against npm packages. For example, if your declaration is for an npm package called 'cool-js-package', it will check if a package named 'cool-js-package' actually exists in npm.

  2. code: in addition to the checks performed in name-only mode, dts-critic will check if your declaration exports match the source JavaScript module exports. For example, if your declaration has a default export, it will check if the JavaScript module also has a default export.

Current checks

Npm declaration

If your declaration is for an npm package:

  1. An npm package with the same name of your declaration's package must exist.
  2. If your declaration has a Definitely Typed header and the header specifies a target version, the npm package must have a matching version.
  3. If you are running under code mode, your declaration must also match the source JavaScript module.

Non-npm declaration

If your declaration is for a non-npm package (in other words, if your declaration has a Definitely Typed header and the header specifies that the declaration file is for a non-npm package):

  1. An npm package with the same name of your declaration's package cannot exist.
  2. If you are running under code mode and a path to the JavaScript source file was provided, your declaration must also match the source JavaScript module.

Planned work

  1. Make sure your module structure fits the source.
  2. Make sure your exported symbols match the source.
  3. Make sure your types match the source types???
  4. Download source based on npm homepage (if it is github).

Note that for real use on Definitely Typed, a lot of these checks need to be pretty loose.

Also

$ node dist/dt.js

Will run dts-critic on every directory inside ../DefinitelyTyped and print errors.

Contributing

Testing

The tests use the Jest framework. To build and execute the tests, run:

$ npm run test

This will build the program and run jest.

Keywords

FAQs

Package last updated on 21 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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