
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
typings-checker
Advanced tools
The tests in DefinitelyTyped verify that correct code type checks.
But this is an easy bar to meet: giving a module an any
type is sufficient to make
its tests type check.
It's just as important that incorrect code not typecheck. There isn't any way to test for this in DT right now. This repo provides a proof of concept for how this could be added. It's modeleled after the way FlowTyped handles things.
Here's what a test for _.find
might look like:
_.find([1, 2, 3], x => x * 1 == 3); // (this is just expected to type check)
// $ExpectError Operator '==' cannot be applied to types 'number' and 'string'.
_.find([1, 2, 3], x => x == 'a');
// $ExpectType number
_.find([1, 2, 3], 1);
// $ExpectError Property 'y' does not exist on type '{ x: number; }'.
_.find([{x:1}, {x:2}, {x:3}], v => v.y == 3);
// $ExpectType { x: number; }
_.find([{x:1}, {x:2}, {x:3}], v => v.x == 3);
Code is expected to type check unless an $ExpectError
directive is used. In this case, an error is required (lack of an error from TypeScript is a test failure).
An $ExpectType
directive tests the type of the expression on the next line. This prevents unexpected any
or {}
types from creeping in.
npm install -g typings-checker
typings-checker --project tsconfig.json your-test.ts your-second-test.ts
--project
Path to the relevant tsconfig.json file
--allow-expect-error
Enables $ExpectError assertions. These can help pin down behavior but they
also prevent tsc from running over your assertions. Disabled by default.
$ npm install -g yarn ts-node
$ yarn
$ ts-node src/index.ts sample.ts
Successes: 6
Failures: 0
FAQs
Positive and negative assertions about TypeScript types and errors
The npm package typings-checker receives a total of 464 weekly downloads. As such, typings-checker popularity was classified as not popular.
We found that typings-checker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.