Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate takes a cue.Value and generates the corresponding TypeScript for all top-level members of that value that have appropriate @cuetsy attributes.
Members that are definitions, hidden fields, or optional fields are ignored.
func NoImportMappingErr ¶
func NoImportMappingErr(d *ast.ImportDecl) error
NoImportMappingErr returns a standard error indicating that no mapping can be made for the provided import statement.
Types ¶
type Concreteness ¶
type Concreteness int
Concreteness is a measure of the level of concreteness of a value, where lower values mean more concrete.
Replicated from cuelang.org/internal/core/adt
const ( BottomLevel Concreteness = iota // Concrete indicates a concrete scalar value, list or struct. Concrete // Constraint indicates a non-concrete scalar value that is more specific, // than a top-level type. Constraint // Type indicates a top-level specific type, for instance, string, // bytes, number, or bool. Type // Any indicates any value, or top. Any )
type Config ¶
type Config struct { // ImportMapper determines how CUE imports are mapped to Typescript imports. // If nil, any non-stdlib import in the CUE source will result in a fatal // error. ImportMapper }
Config governs certain variable behaviors when converting CUE to Typescript.
type DeclPair ¶ added in v0.0.2
type DeclPair struct { // The generated type declaration. T ts.Decl // The default declaration corresponding to T. D ts.Decl }
DeclPair represents a generated type declaration, with its corresponding default declaration.
type ImportMapper ¶
type ImportMapper func(*ast.ImportDecl) (string, error)
An ImportMapper takes an ImportDecl and returns a string indicating the import statement that should be used in the corresponding typescript, or an error if no mapping can be made.
type NewConfig ¶
type NewConfig struct { // Subpath is the path within the cue.Instance that cuetsy should treat as the // root object to be rendered. Optional. Subpath cue.Path // Self indicates that, rather than rendering all the attribute-annotated // children of provided instance, the instance itself should be rendered. Self bool // InjectCuetsyAttrs is an optional set of attribute bodies to be dynamically // injected onto values as they're being rendered. // // The keys will be passed to cue.ParsePath(). The value will be treated as // the body of a @cuetsy attribute (@cuetsy(<value>)) for values encountered at // that path, relative to the root. InjectCuetsyAttrs map[string]string }
type TSType ¶ added in v0.0.2
type TSType string
TSType strings indicate the kind of TypeScript declaration to which a CUE value should be translated. They are used in both @cuetsy attributes, and in calls to certain methods.
const ( // TypeAlias targets conversion of a CUE value to a TypeScript `type` // declaration, which are called type aliases: // https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-aliases TypeAlias TSType = "type" // TypeInterface targets conversion of a CUE value to a TypeScript `interface` // declaration: // https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#interfaces TypeInterface TSType = "interface" // TypeEnum targets conversion of a CUE value to a TypeScript `enum` // declaration: // https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#enums TypeEnum TSType = "enum" )
type TypeMapper ¶
type TypeMapper interface { Value() cue.Value Kind() cue.Kind Concreteness() Concreteness String() string }
TypeMapper is a general interface to describe a mapping between cue.Value and typescript kinds and types. Will necessarily need to omit expressions.