
Product
Introducing Module Reachability: Focus on the Vulnerabilities That Matter
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
eslint-plugin-expect-type
Advanced tools
ESLint plugin with ^? Twoslash, $ExpectError, and $ExpectType type assertions. 🧩
ESLint plugin with `^?` Twoslash, `$ExpectError`, and `$ExpectType` type assertions. 🧩
let value = 9001;
// ^? let value: number
// $ExpectError
value = "over nine thousand";
// $ExpectType number
9001;
Make sure you have TypeScript and @typescript-eslint/parser installed, then install the plugin:
npm i -D eslint-plugin-expect-type
See typescript-eslint's Getting Started docs for how to run ESLint on TypeScript files.
Add the following options to your ESLint configuration file:
import expectType from "eslint-plugin-expect-type/configs/recommended";
export default [
// your other ESLint configurations
expectType,
];
For CommonJS, use
const expectType = require("eslint-plugin-expect-type/configs/recommended").default;
.
Then, you'll be able to use ^?
, $ExpectError
, $ExpectType
, and $ExpectTypeSnapshot
comments in code assert on types.
If you're still using the legacy ESLint configuration file format:
{
"extends": ["plugin:expect-type/recommended"],
"plugins": ["expect-type"]
}
💼 Configurations enabled in.
✅ Set in the recommended
configuration.
🔧 Automatically fixable by the --fix
CLI option.
💭 Requires type information.
Name | Description | 💼 | 🔧 | 💭 |
---|---|---|---|---|
expect | Expects type error, type snapshot, or type. | ✅ | 🔧 | 💭 |
You might consider using other popular libraries and tools that can run type assertions:
expectTypeOf('abc').toMatchTypeOf<string>()
.expectType<string>('abc')()
..d.ts
definition files.describe()
and test()
helpers, expect
style assertions and a mighty test runner which allows to use specified version of TypeScript.assertType
and expectTypeOf
assertions.eslint-plugin-expect-type
mirrors the DefinitelyTyped TypeScript Support Window.
Roughly, that's major versions of TypeScript less than 2 years old.
Many thanks to @ibezkrovnyi for creating the initial version and core infrastructure of this package! 💖
💙 This package was templated with create-typescript-app.
FAQs
ESLint plugin with ^? Twoslash, $ExpectError, and $ExpectType type assertions. 🧩
The npm package eslint-plugin-expect-type receives a total of 8,677 weekly downloads. As such, eslint-plugin-expect-type popularity was classified as popular.
We found that eslint-plugin-expect-type 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.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
Product
Socket is introducing a new way to organize repositories and apply repository-specific security policies.
Company News
Socket’s acquisition of Coana brings best-in-class reachability analysis to application security teams globally, cementing Socket’s position as the leader in software supply chain security.