New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tsd-lite

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsd-lite

Test your TypeScript types easily

  • 0.7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
923
decreased by-87.09%
Maintainers
1
Weekly downloads
 
Created
Source

tsd-lite

Test your TypeScript types easily.

version license node-ci

This is a lighter version of tsd. Slightly reworked codebase allows tsd-lite to be a tool which simply tests your types.

Note This library is intended for programmatic use only. For an integration with Jest see jest-runner-tsd, if you prefer standalone CLI implementation check tsd-lite-cli.

Motivation

While tsd suites perfectly for JavaScript libraries which declare their types in .d.ts files, its usage with monorepos written in TypeScript may become cumbersome. tsd-lite is an attempt to address these and similar issues.

Differences from tsd

  • tsd-lite performs only type testing without any additional checks or rules.
  • Exposes only general type related assertions: expectAssignable, expectDeprecated, expectType and their counterparts. Currently other APIs (like expectNever, expectDocCommentIncludes and printType) are not implement.
  • Comes with no default compiler options.
  • Reads TypeScript compiler options from the nearest tsconfig.json for each test file (does not read options from package.json).
  • tsd-lite is optionally strict. You should add "strict": true to the nearest tsconfig.json (it can be project or test specific) to use strict assertions.
  • @tsd/typescript package is moved to peer dependencies.
  • tsd-lite allows only programmatic usage.

Install

yarn add -D tsd-lite @tsd/typescript
# or
npm install -D tsd-lite @tsd/typescript

Remember to install @tsd/typescript. It is a required peer dependency.

Usage

import tsdLite from "tsd-lite";

const { assertionsCount, tsdResults } = tsdLite(
  "/absolute/path/to/testFile.test.ts"
);

API Reference

tsdLite(testFilePath: string)

The exported function takes fully resolved path to a test file as an argument and returns an object:

{
  assertionsCount: number;
  tsdResults: Array<{
    messageText: string | ts.DiagnosticMessageChain;
    file?: ts.SourceFile;
    start?: number;
  }>;
}

tsd-lite will throw if TS compiler encountered an error while parsing tsconfig.json or a syntax error is found while compiling the code.

License

MIT

Keywords

FAQs

Package last updated on 08 Mar 2023

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