Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 8, 2019. It is now read-only.

NotWoods/assert-typescript-errors

Repository files navigation

assert-typescript-errors

Automatically verify that certain test files fail to pass TypeScript type checks.

This package checks the output from TypeScript's compiler (with the --pretty flag expected to be false) and ensures that it matches with the line numbers you specify.

Usage

As a module

import { exec } from 'child_process';
import { assertTypeScriptErrors } from 'assert-typescript-errors';
/**
 * Specify the lines that should have errors in your test files.
 */
const assertions = {
 'test/type-test.ts': [
 29, // Individual line numbers can be used
 '57-58', // Ranges of line numbers can also be specified. Equivalent to 57, 58.
 ],
 'test/type-test-two.ts': [31, 39, '45-51'],
};
exec('tsc --pretty false', (err, stdout) => {
 assertTypeScriptErrors(stdout, assertions).catch(console.error);
});

From the command line

echo '{ "type-test.ts": [29, "56-60"] }' > assertions.json
tsc --pretty false | assert-ts-errors assertions.json

About

Assert that TypeScript finds an error in your test files.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /