typescript

package
v0.0.0-...-4748787 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2019 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var False = Code("false")
View Source
var Null = Code("null")
View Source
var True = Code("true")
View Source
var Undefined = Code("undefined")

Functions

func CreateWriter

func CreateWriter() codeWriter

Types

type BlockDeclaration

type BlockDeclaration struct {
	// contains filtered or unexported fields
}

func Block

func Block(lines ...string) *BlockDeclaration

func (*BlockDeclaration) Append

func (self *BlockDeclaration) Append(code string) *BlockDeclaration

func (*BlockDeclaration) AppendCode

func (self *BlockDeclaration) AppendCode(code Writable) *BlockDeclaration

func (*BlockDeclaration) WriteCode

func (self *BlockDeclaration) WriteCode(writer CodeWriter)

type ClassDeclaration

type ClassDeclaration struct {
	// contains filtered or unexported fields
}

ClassDeclaration declares a class

func Class

func Class(name string) *ClassDeclaration

Class starts building a new class. returns ClassDeclaration

func (*ClassDeclaration) AddMembers

func (cls *ClassDeclaration) AddMembers(members ...Writable) *ClassDeclaration

AddMembers adds methods or properties to a class

func (*ClassDeclaration) Constructor

func (cls *ClassDeclaration) Constructor() *MethodDeclaration

Constructor starts building a constructor on the class. returns MethodDeclaration

func (*ClassDeclaration) Export

func (cls *ClassDeclaration) Export() *ClassDeclaration

Exported marks a class as exported

func (*ClassDeclaration) Extends

func (cls *ClassDeclaration) Extends(types ...string) *ClassDeclaration

Extends adds types that the classes extends

func (*ClassDeclaration) Implements

func (cls *ClassDeclaration) Implements(types ...string) *ClassDeclaration

Implements adds types that the classes implements

func (*ClassDeclaration) Method

func (cls *ClassDeclaration) Method(name string) *MethodDeclaration

Method starts building a new method on the class. returns MethodDeclaration

func (*ClassDeclaration) Private

func (cls *ClassDeclaration) Private() *ClassDeclaration

Private marks a class as private

func (*ClassDeclaration) Property

func (cls *ClassDeclaration) Property(typeName string, name string) *PropertyDeclaration

Property adds a property to the class. returns PropertyDeclaration

func (*ClassDeclaration) Public

func (cls *ClassDeclaration) Public() *ClassDeclaration

Public marks a class as public

func (*ClassDeclaration) WriteCode

func (cls *ClassDeclaration) WriteCode(writer CodeWriter)

WriteCode writes the class to the writer

type CodeWriter

type CodeWriter interface {
	Begin()
	End()
	Eol()
	Write(code string)
}

type EnumDeclaration

type EnumDeclaration struct {
	// contains filtered or unexported fields
}

EnumDeclaration declares an enum

func Enum

func Enum(name string) *EnumDeclaration

Enum starts building a new enum. returns EnumDeclaration

func (*EnumDeclaration) AddMembers

func (enum *EnumDeclaration) AddMembers(members ...Writable) *EnumDeclaration

AddMembers adds members to the enum

func (*EnumDeclaration) Const

func (enum *EnumDeclaration) Const() *EnumDeclaration

Const makes the enum a constant

func (*EnumDeclaration) Export

func (enum *EnumDeclaration) Export() *EnumDeclaration

Exported makes the enum a exported

func (*EnumDeclaration) Member

func (enum *EnumDeclaration) Member(name string) *EnumMemberDeclaration

Member adds a member to the enum. returns EnumMemberDeclaration

func (*EnumDeclaration) WriteCode

func (enum *EnumDeclaration) WriteCode(writer CodeWriter)

WriteCode writes the enum to the writer

type EnumMemberDeclaration

type EnumMemberDeclaration struct {
	// contains filtered or unexported fields
}

EnumMemberDeclaration declares an enum member

func EnumMember

func EnumMember(name string) *EnumMemberDeclaration

EnumMember creates a new enum member

func (*EnumMemberDeclaration) Value

Value sets the enums value

func (*EnumMemberDeclaration) WriteCode

func (enum *EnumMemberDeclaration) WriteCode(writer CodeWriter)

WriteCode writes the enum to the writer

type ImportDeclaration

type ImportDeclaration struct {
	// contains filtered or unexported fields
}

ImportDeclaration declares an import

func DefaultImport

func DefaultImport(module string, as string) *ImportDeclaration

DefaultImport creates a default import. import * as foo from 'module';

func NamedImport

func NamedImport(module string, params ...string) *ImportDeclaration

NamedImport creates a default import. import * as foo from 'module';

func (*ImportDeclaration) WriteCode

func (imp *ImportDeclaration) WriteCode(writer CodeWriter)

WriteCode writes the imports to the writer

type InterfaceDeclaration

type InterfaceDeclaration struct {
	// contains filtered or unexported fields
}

InterfaceDeclaration declares an interface

func Interface

func Interface(name string) *InterfaceDeclaration

Interface starts building a new interface. returns InterfaceDeclaration

func (*InterfaceDeclaration) AddMembers

func (iface *InterfaceDeclaration) AddMembers(members ...Writable) *InterfaceDeclaration

AddMembers adds additional members to the interface

func (*InterfaceDeclaration) Export

func (iface *InterfaceDeclaration) Export() *InterfaceDeclaration

Export marks the interface as exported

func (*InterfaceDeclaration) Extends

func (iface *InterfaceDeclaration) Extends(types ...string) *InterfaceDeclaration

Extends adds additional types to extend the interface

func (*InterfaceDeclaration) Method

func (iface *InterfaceDeclaration) Method(name string) *MethodDeclaration

Method starts building a new method on the interface. returns MethodDeclaration

func (*InterfaceDeclaration) Property

func (iface *InterfaceDeclaration) Property(typeName string, name string) *PropertyDeclaration

Property starts building a new property on the interface. returns PropertyDeclaration

func (*InterfaceDeclaration) WriteCode

func (iface *InterfaceDeclaration) WriteCode(writer CodeWriter)

WriteCode writes the interface to the writer

type MethodDeclaration

type MethodDeclaration struct {
	// contains filtered or unexported fields
}

MethodDeclaration declares an method

func Constructor

func Constructor() *MethodDeclaration

Constructor starts building a new constructor. returns MethodDeclaration

func Method

func Method(name string) *MethodDeclaration

Method starts building a new method. returns MethodDeclaration

func (*MethodDeclaration) AddParams

func (method *MethodDeclaration) AddParams(params ...Writable) *MethodDeclaration

AddParams adds parameters to the method

func (*MethodDeclaration) Async

func (method *MethodDeclaration) Async() *MethodDeclaration

Async marks the method as async

func (*MethodDeclaration) Body

func (method *MethodDeclaration) Body(lines ...string) *BlockDeclaration

Body starts building the method body. returns BlockDeclaration

func (*MethodDeclaration) Param

func (method *MethodDeclaration) Param(typeName string, name string) *ParamDeclaration

Param adds a parameter to the method

func (*MethodDeclaration) Private

func (method *MethodDeclaration) Private() *MethodDeclaration

Private marks the method as private

func (*MethodDeclaration) Public

func (method *MethodDeclaration) Public() *MethodDeclaration

Public marks the method as public

func (*MethodDeclaration) Returns

func (method *MethodDeclaration) Returns(returnType string) *MethodDeclaration

Returns sets the return type of the method

func (*MethodDeclaration) WriteCode

func (method *MethodDeclaration) WriteCode(writer CodeWriter)

WriteCode writes the method to the writer

type NamespaceDeclaration

type NamespaceDeclaration struct {
	// contains filtered or unexported fields
}

NamespaceDeclaration declares a namespace

func Namespace

func Namespace(namespace string) *NamespaceDeclaration

Namespace creates a NamespaceDeclaration

func (*NamespaceDeclaration) AddDeclarations

func (ns *NamespaceDeclaration) AddDeclarations(declarations ...Writable) *NamespaceDeclaration

AddDeclarations adds declarations to the namespace

func (*NamespaceDeclaration) AddImports

func (ns *NamespaceDeclaration) AddImports(imports ...Writable) *NamespaceDeclaration

AddImports adds imports to the namespace

func (*NamespaceDeclaration) DefaultImport

func (ns *NamespaceDeclaration) DefaultImport(module string, as string) *NamespaceDeclaration

DefaultImport adds a default import

func (*NamespaceDeclaration) NamedImport

func (ns *NamespaceDeclaration) NamedImport(module string, params ...string) *NamespaceDeclaration

NamedImport adds a named import

func (*NamespaceDeclaration) WithReference

func (ns *NamespaceDeclaration) WithReference(filePath string) *NamespaceDeclaration

WithReference adds a file reference for namespace compilation

func (*NamespaceDeclaration) WriteCode

func (ns *NamespaceDeclaration) WriteCode(writer CodeWriter)

WriteCode writes the namespace to the writer

type ParamDeclaration

type ParamDeclaration struct {
	// contains filtered or unexported fields
}

ParamDeclaration declares an parameter

func Param

func Param(typeName string, name string) *ParamDeclaration

Param creates a new ParamDeclaration

func (*ParamDeclaration) Default

func (param *ParamDeclaration) Default(defaultValue Writable) *ParamDeclaration

Default sets the default value of the param

func (*ParamDeclaration) Private

func (param *ParamDeclaration) Private() *ParamDeclaration

Private marks the parameter as private. Only for constructors

func (*ParamDeclaration) Public

func (param *ParamDeclaration) Public() *ParamDeclaration

Public marks the parameter as public. Only for constructors

func (*ParamDeclaration) Readonly

func (param *ParamDeclaration) Readonly() *ParamDeclaration

Readonly marks the parameter as readonly. Only for constructors

func (*ParamDeclaration) WriteCode

func (param *ParamDeclaration) WriteCode(writer CodeWriter)

WriteCode writes the param to the writer

type PropertyDeclaration

type PropertyDeclaration struct {
	// contains filtered or unexported fields
}

PropertyDeclaration declares a property

func Property

func Property(typeName string, name string) *PropertyDeclaration

Property starts building a new property. returns PropertyDeclaration

func (*PropertyDeclaration) Initializer

func (prop *PropertyDeclaration) Initializer(initializer string) *PropertyDeclaration

Initializer sets the properties initializer

func (*PropertyDeclaration) Optional

func (prop *PropertyDeclaration) Optional() *PropertyDeclaration

Optional marks the property as optional

func (*PropertyDeclaration) Private

func (prop *PropertyDeclaration) Private() *PropertyDeclaration

Private marks the property as private

func (*PropertyDeclaration) Public

func (prop *PropertyDeclaration) Public() *PropertyDeclaration

Public marks the property as public

func (*PropertyDeclaration) Readonly

func (prop *PropertyDeclaration) Readonly() *PropertyDeclaration

Readonly marks the property as readonly

func (*PropertyDeclaration) Static

func (prop *PropertyDeclaration) Static() *PropertyDeclaration

Static marks the property as static. Can only be used on classes, not interfaces

func (*PropertyDeclaration) WriteCode

func (prop *PropertyDeclaration) WriteCode(writer CodeWriter)

WriteCode writes the property to the writer

type UnitDeclaration

type UnitDeclaration struct {
	// contains filtered or unexported fields
}

func Unit

func Unit() *UnitDeclaration

func (*UnitDeclaration) AddDeclarations

func (unit *UnitDeclaration) AddDeclarations(declarations ...Writable) *UnitDeclaration

AddDeclarations adds declarations to the unit

func (*UnitDeclaration) AddImports

func (unit *UnitDeclaration) AddImports(imports ...Writable) *UnitDeclaration

func (*UnitDeclaration) AddNamespaces

func (unit *UnitDeclaration) AddNamespaces(namespaces ...Writable) *UnitDeclaration

func (*UnitDeclaration) Code

func (unit *UnitDeclaration) Code() string

func (*UnitDeclaration) DefaultImport

func (unit *UnitDeclaration) DefaultImport(module string, as string) *UnitDeclaration

func (*UnitDeclaration) NamedImport

func (unit *UnitDeclaration) NamedImport(module string, params ...string) *UnitDeclaration

func (*UnitDeclaration) Namespace

func (unit *UnitDeclaration) Namespace(namespace string) *NamespaceDeclaration

func (*UnitDeclaration) WriteCode

func (unit *UnitDeclaration) WriteCode(writer CodeWriter)

type Writable

type Writable interface {
	WriteCode(writer CodeWriter)
}

type WritableCode

type WritableCode struct {
	// contains filtered or unexported fields
}

func C

func C(code string) *WritableCode

func Code

func Code(code string) *WritableCode

func Int

func Int(value int) *WritableCode

func Str

func Str(value string) *WritableCode

func (*WritableCode) WriteCode

func (self *WritableCode) WriteCode(writer CodeWriter)

Jump to

Keyboard shortcuts

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