
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Magic Type 🎩 Use Your TypeScript definitions at runtime. Powered by Manta Style. <img src="https://img.shields.io/
🎩 Use Your TypeScript definitions at runtime. Powered by Manta Style.
yarn global add magic-type
npm install -g magic-type
You could also use Magic Type locally as well.
Let's take the following code as an example.
// typings/api.ts
export type MyAPIRequest = {
time: number;
input: string;
};
Usage: magictype [options]
Options:
-V, --version output the version number
-i --inputFile <file> The entrypoint of files to be compiled
-o --outputDir <dir> The output directory of compiled files
-c --cjs Transpile modules to CommonJS (Otherwise it will output ES modules)
-h, --help output usage information
import { MyAPIRequest } from "./api";
// Use Magic Types as normal TypeScript types
type MyType = {
key: MyAPIRequest;
};
// Use Magic Type at Runtime
// Check if user input matches MyAPIRequest
function checkMyInput(input: any) {
return MyAPIRequest.validate(input);
}
// Format user input to match MyAPIRequest
function formatMyInput(input: any) {
return MyAPIRequest.format(input);
}
// Generate a mock MyAPIRequest data
function getMockData() {
return MyAPIRequest.deriveLiteral([]).mock();
}
Developer Experience with TypeScript's type guard

Runtime Screenshot:

Please be noted there's no warnings against unsupported syntax yet (And Magic Type may crash as well). Please kindly check by yourself.
extends keyword in interface declaration will be ignored.A | B) and intersection(A & B) on index signatures are not supported.infer keywordReturnType<T> and InstanceType<T> are not supported due to unsupported infer keyword and functions.Magic Type is MIT licensed
FAQs
Magic Type 🎩 Use Your TypeScript definitions at runtime. Powered by Manta Style. <img src="https://img.shields.io/
We found that magic-type demonstrated a not healthy version release cadence and project activity because the last version was released 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.