You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@types/hast

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/hast

TypeScript definitions for hast


Version published
Weekly downloads
9.9M
increased by1.6%
Maintainers
1
Created
Weekly downloads
 

Package description

What is @types/hast?

The @types/hast package provides TypeScript type definitions for HAST (Hypertext Abstract Syntax Tree) format, which is a virtual DOM format for HTML and XML. This allows developers to work with HAST trees in TypeScript projects with type safety, enabling better development experience, auto-completion, and error checking.

What are @types/hast's main functionalities?

Creating a HAST node

This code sample demonstrates how to create a simple HAST node representing a paragraph element containing the text 'Hello, world!'. The node is typed, ensuring that only valid properties and child nodes are used.

{"type": "element", "tagName": "p", "properties": {}, "children": [{"type": "text", "value": "Hello, world!"}]}

Type-checking a HAST tree

This code sample shows how to type-check a HAST tree to safely access properties. It specifically checks if a node is an anchor ('a') element and logs its 'href' property if available.

import {Element} from 'hast';

function processNode(node: Element): void {
  if (node.tagName === 'a' && node.properties) {
    console.log(node.properties.href);
  }
}

Other packages similar to @types/hast

Readme

Source

Installation

npm install --save @types/hast

Summary

This package contains type definitions for hast (https://github.com/syntax-tree/hast).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hast/v2.

Additional Details

  • Last updated: Wed, 27 Dec 2023 20:07:01 GMT
  • Dependencies: @types/unist

Credits

These definitions were written by lukeggchapman, Junyoung Choi, and Christian Murphy.

FAQs

Package last updated on 27 Dec 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc