Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
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,
];
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 type assertion libraries in the TypeScript ecosystem:
expectTypeOf('abc').toMatchTypeOf<string>()
.expectType<string>('abc')()
..d.ts
definition files.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! 💖
Batuhan Wilhelm 🐛 💻 | Colin 🐛 | Dan Vanderkam 💻 🚧 | Daniel Nagy 🐛 | Dominik Dorfmeister 📖 | Francesco Trotta 💻 | Igor Bezkrovnyi 🐛 💻 📖 🚧 |
Josh Goldberg ✨ 🐛 💻 📖 🚧 🚇 🤔 | Russell Davis 💻 | detachhead 🤔 | nirtamir2 📖 |
💙 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 6,921 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 3 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.