Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
@types/estree
Advanced tools
TypeScript definitions for estree
Weekly downloads
Package description
The @types/estree package provides TypeScript type definitions for the ESTree spec, which is a specification for representing JavaScript source code as an abstract syntax tree (AST). These type definitions allow TypeScript developers to work with ASTs in a type-safe manner, ensuring that the structure of the tree is consistent with the ESTree specification.
Defining AST Node Types
This code sample represents a simple AST for a JavaScript program that declares a constant variable 'x' with the value 10. The @types/estree package provides the types that describe the structure of this AST.
{"type": "Program","sourceType": "module","body": [{"type": "VariableDeclaration","declarations": [{"type": "VariableDeclarator","id": {"type": "Identifier","name": "x"},"init": {"type": "Literal","value": 10,"raw": "10"}}],"kind": "const"}]}
Type Checking AST Nodes
This code sample demonstrates how to use the Node type from @types/estree to type-check an AST node and handle it accordingly based on its type.
import { Node } from 'estree';
function processNode(node: Node) {
if (node.type === 'BinaryExpression') {
// Handle binary expression
}
}
Acorn is a JavaScript parser that produces an AST based on the ESTree specification. While @types/estree provides type definitions, Acorn provides the actual parsing functionality to generate ASTs from JavaScript code.
Espree is an ECMAScript parser that is built on top of Acorn. Similar to Acorn, it outputs an AST conforming to the ESTree spec. Espree extends Acorn with additional features and ES6+ support.
Babel-types is a part of the Babel compiler that provides builders, validators, and converters for Babel's AST, which is slightly different from the ESTree spec. It serves a similar purpose to @types/estree but for Babel's AST format.
Readme
npm install --save @types/estree
This package contains type definitions for estree (https://github.com/estree/estree).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree.
These definitions were written by RReverser.
FAQs
TypeScript definitions for estree
The npm package @types/estree receives a total of 21,910,162 weekly downloads. As such, @types/estree popularity was classified as popular.
We found that @types/estree demonstrated a healthy version release cadence and project activity because the last version was released less than 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
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.