![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
ts-expect-error-validator
Advanced tools
Since ts-expect-error does not have the ability to specify only the errors that we want to ignore, and instead suppresses all errors, it makes managing errors more challenging. This package provides a command-line tool to validate expected TypeScript erro
Since ts-expect-error does not have the ability to specify only the errors that we want to ignore, and instead suppresses all errors, it makes managing errors more challenging. This package provides a command-line tool to validate expected TypeScript errors with the main goal of making error management easier.
Install the package:
yarn add -D ts-expect-error-validator
class User {
// Specify only a TS code for validation
// @ts-expect-error [TS6133]
private myNumber: string | undefined;
}
function getMyData(): string | undefined {
return 'myData';
}
// Specify the message and a TS code for validation for `strict` mode
// @ts-expect-error [TS2532 - Object is possibly 'undefined']
getMyData().length;
// Other approach for ignoring a line:
getMyData().length; // @ts-expect-error [TS2532]
// Specify several TS code errors for validation for a line:
// @ts-expect-error [TS2322, TS6133]
const object: { a: number } = { b: 5 };
// Specify several TS code errors with message description for validation
// @ts-expect-error [TS6133 - 'object' is declared but its value is never read, TS2322 - Type '{ b: number; }' is not assignable to type '{ a: number; }']
const sample: { a: number } = { b: 5 };
By default, the file extensions analyzed are tsx
and ts
.
Option | Description |
---|---|
--tsConfigPath=<PATH> | Path to the tsconfig.json file to use. Defaults to the tsconfig.json in the current directory. |
--restore | Since we have to change all @ts-expect-error to something else, this changes the content file. You can use this option to restore changed files. |
--sourcePath=<PATH> | Path to the directory or the file containing @ts-expect-error to validate. You can specify several folders or files to make search more productive. |
--outputFormat=<FORMAT> | The output format. Can be either json or human . Defaults to human . |
--quiet | If present, suppresses all output except for report results. |
--validationMode=<MODE> | Specifies the validation mode to use. Can be either default or strict . In default mode , only the expected error codes are validated. In strict mode, the error code and the first line of the error description are validated. Notice that strict mode is in alpha version. Default is default . |
//a package.json file
...
"scripts": {
"ts-expect-error-validator": "ts-expect-error-validator --tsConfigPath=tsconfig.json --restore --sourcePath=src/myDir --sourcePath=src/someTsFile.ts --reportFormat=json --quiet"
}
...
//a cli comand
yarn ts-expect-error-validator
yarn ts-expect-error-validator $(git diff --name-only HEAD | grep "\.ts$" | xargs -I {} echo "--sourcePath={}" | tr '\n' ' ')
This library is released under the MIT License.
FAQs
Since ts-expect-error does not have the ability to specify only the errors that we want to ignore, and instead suppresses all errors, it makes managing errors more challenging. This package provides a command-line tool to validate expected TypeScript erro
The npm package ts-expect-error-validator receives a total of 73 weekly downloads. As such, ts-expect-error-validator popularity was classified as not popular.
We found that ts-expect-error-validator 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.