
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@esmbly/transformer-v8
Advanced tools
An Esmbly transformer that transforms plain JavaScript files to TypeScript by using a V8 type profile that is collected while running a test suite
@esmbly/transformer-v8
Turn your tests into types
Transform JavaScript files to TypeScript by collecting V8 runtime type information during test runs.
# Using Yarn:
yarn add @esmbly/transformer-v8
# Or, using NPM:
npm install @esmbly/transformer-v8 --save
Check out Using the V8 transformer for a step-by-step guide on how to get started with @esmbly/transformer-v8
and the command-line interface.
The @esmbly/transformer-v8
transforms JavaScript files to TypeScript based on type information collected from V8. In order to use it, make sure you have @esmbly/cli
installed. Under the hood, @esmbly/transformer-v8
uses the experimental Inspector API and the V8 inspector protocol which requires you to have at least Node.js version 10 installed.
In order to collect a V8 type profile about a JavaScript program - the program needs to be executed. When the program is executed, type information can be collected from V8 via the V8 inspector protocol. If a program is covered by a test suite, the test suite can be executed in order to run the program and retrieve a type profile from V8.
The following Esmbly configuration will run jest
in order to extract a type profile, and then transform all JavaScript files located in the src
directory to TypeScript. Files are outputted to the dist
directory.
// esmbly.config.js
const V8 = require('@esmbly/transformer-v8');
module.exports = {
input: ['./src/**/*.js'],
transformers: [
V8.createTransformer({
testCommand: `jest`,
}),
],
output: [
{
format: '.ts',
outDir: 'dist',
rootDir: 'src'
},
],
};
The createTransformer()
method accepts an optional configuration object (see the V8TransformerOptions interface). The following options are possible.
Option | Description | Type | Default |
---|---|---|---|
testCommand | The test command to run in order to extract a type profile, e.g. jest --runInBand | string | |
debug | Debug whats being printed to stdout/stderr during the test run. | boolean | false |
customRules (optional) | An object containing any custom rules which should be applied (existing rules can be overridden). Check out the custom-rule example for further details. | CustomRules |
The long term goal is to support any test runner, including simply running node
to invoke a program that executes the specified input files. Currently, the following test runners are supported:
The type information that can be retrieved from V8 is somewhat experimental. All primitive types are supported, as well as custom classes. However, V8 does provide any detailed information about arrays or objects literals which will be interpreted as any[]
and Object
.
@esmbly/transformer-v8
and @esmbly/transformer-wasm
.@esmbly/transformer-v8
and @esmbly/transformer-wasm
.@esmbly/transformer-v8
and @esmbly/transformer-wasm
.All types of contributions are very much welcome. Check out our Contributing Guide for instructions on how to get started.
FAQs
An Esmbly transformer that transforms plain JavaScript files to TypeScript by using a V8 type profile that is collected while running a test suite
The npm package @esmbly/transformer-v8 receives a total of 9 weekly downloads. As such, @esmbly/transformer-v8 popularity was classified as not popular.
We found that @esmbly/transformer-v8 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.