Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@typeonly/loader
Advanced tools
TypeOnly aims to be the pure typing part of TypeScript. The TypeOnly parser generates a .to.json
file, which is a bundle that contains metadata extracted from .d.ts
typing files. Then, this package provides an API to read these RTO files. It brings typing metadata at runtime.
At first, it is necessary to follow the tutorial of TypeOnly in order to generate a .to.json
file based on your TypeScript definitions. After this step, you have the following file: dist/types.to.json
.
Now, add @typeonly/loader
to the project:
npm install @typeonly/loader
Create a file src/main.js
with the following content:
// src/main.js
const { loadModules, literals } = require("@typeonly/loader");
const modules = loadModules({
bundle: require(`./types.to.json`)
});
const { ColorName } = modules["./drawing"].namedTypes;
console.log("Color names:", literals(ColorName, "string"));
If you write this code in a TypeScript source file, simply replace the require
syntax with a standard import
.
We can execute our program:
$ node src/main.js
Color names: [ 'red', 'green', 'blue' ]
Yes, it’s as easy as it seems: the list of color names is now available at runtime.
Notice: The TypeOnly parser is used at build time. At runtime, our code only use @typeonly/loader
which is a lightweight wrapper for .to.json
files.
With VS Code, our recommanded plugin is:
ms-vscode.vscode-typescript-tslint-plugin
)FAQs
Brings types and interfaces from TypeScript at runtime.
The npm package @typeonly/loader receives a total of 303 weekly downloads. As such, @typeonly/loader popularity was classified as not popular.
We found that @typeonly/loader demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.