![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Test your TypeScript types easily.
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 CLI implementation see jest-runner-tsd
.
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.
tsd
tsd-lite
performs only type testing without any additional checks or rules.expectAssignable
, expectDeprecated
, expectType
and their counterparts. The printType
helper is removed.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.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.
import tsdLite from "tsd-lite";
const { assertionsCount, tsdResults } = tsdLite(
"/absolute/path/to/testFile.test.ts"
);
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.
FAQs
Test your TypeScript types easily
The npm package tsd-lite receives a total of 6,276 weekly downloads. As such, tsd-lite popularity was classified as popular.
We found that tsd-lite demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.