Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@peerigon/typescript-exercises-tools
Advanced tools
Tools for writing and validating TypeScript exercises
Tools for writing and validating TypeScript exercises.
This module allows you to annotate expected type errors in your TypeScript code like this:
export const add = (a: number, b: string) => {
return a + b;
};
// 💥 Expect error 2345: Argument of type '4' is not assignable to parameter of type...
add(3, 4);
With the TypeScript language service plugin provided by this module, these expected type errors will show up as a suggestion instead of an error:
Furthermore, these comments will cause the editor to show an error if there is no type error at this location:
At the time of writing, only editors use TypeScript language service plugins. Calling tsc
from the command line will not execute the plugin. That's why there is also a programmatic API that allows you to do assertions on the program:
import { assertProgramToOnlyHaveExpectedErrors } from "@peerigon/typescript-exercises-tools/tests";
test("The program has only expected errors", () => {
assertProgramToOnlyHaveExpectedErrors("/path/to/module.ts");
});
This module is ideal for:
npm install @peerigon/typescript-exercises-tools
Now you need to add the TypeScript language service plugin to your tsconfig.json
:
{
"compilerOptions": {
"plugins": [
{
"name": "@peerigon/typescript-exercises-tools"
}
]
}
}
Please note that you need to configure your editor to use your local TypeScript version. Otherwise TypeScript may not find the plugin. If you're using VSCode, create a file in your repository at .vscode/settings.json
and add this:
{
"typescript.tsdk": "node_modules/typescript/lib"
}
Compiles the program at the given programPath
and throws the first unexpected error it encounters. It's recommended to use an absolute path. If you don't pass any compilerOptions
to this function, it uses TypeScript's internal findConfigFile()
to locate the closest tsconfig.json
to programPath
.
import { assertProgramToOnlyHaveExpectedErrors } from "@peerigon/typescript-exercises-tools/tests";
assertProgramToOnlyHaveExpectedErrors("/path/to/module.ts"); // may throw
assertProgramToOnlyHaveExpectedErrors(
"/path/to/module.ts",
{ strict: true }, // custom compiler options
);
Unlicense
FAQs
Tools for writing and validating TypeScript exercises
The npm package @peerigon/typescript-exercises-tools receives a total of 0 weekly downloads. As such, @peerigon/typescript-exercises-tools popularity was classified as not popular.
We found that @peerigon/typescript-exercises-tools demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.