parser

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package parser provides a Parse function for parsing TypeScript source files into an abstract syntax tree (AST).

Example
package main

import (
	"fmt"

	"github.com/armsnyder/typescript-ast-go/parser"
)

func main() {
	src := []byte(`
		export interface ProgressParams<T> {
		  /**
		   * The progress token provided by the client or server.
		   */
		  token: ProgressToken;

		  /**
		   * The progress data.
		   */
		  value: T;
		}`)
	sourceFile := parser.Parse(src)
	fmt.Printf("Parsed %T", sourceFile.Statements[0])
}
Output:

Parsed *ast.InterfaceDeclaration

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(source []byte) *ast.SourceFile

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL