typescript

package
v0.0.0-...-2016107 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Overview

Package typescript provides tools for generating native TypeScript types from Thema's lineage and schema abstractions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTypes

func GenerateTypes(sch thema.Schema, cfg *TypeConfig) (*ast.File, error)

GenerateTypes generates native TypeScript types and defaults corresponding to the provided Schema.

Types

type TypeConfig

type TypeConfig struct {
	// CuetsyConfig is passed directly to cuetsy, the underlying code generator.
	//
	// If nil provided, defaults to Export: true.
	CuetsyConfig *cuetsy.Config

	// Group indicates that the type is a grouped lineage - the root schema itself
	// does not represent an object that is ever expected to exist independently,
	// but each of its top-level fields do.
	//
	// NOTE - https://github.com/grafana/thema/issues/62 is the issue for formalizing
	// the group concept. Fixing that issue will obviate this field. Once fixed,
	// this field will be ignored, deprecated, and eventually removed.
	Group bool

	// RootName specifies the name to use for the type representing the root of the
	// schema. If empty, this defaults to titlecasing of the lineage name.
	//
	// No-op if Group is true.
	RootName string

	// RootAsType controls whether the root schema is generated as a TypeScript
	// interface type (false) or alias type (true).
	//
	// No-op if Group is true.
	RootAsType bool
}

TypeConfig governs the behavior of GenerateTypes.

Jump to

Keyboard shortcuts

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