Documentation ¶
Index ¶
- Constants
- func List[F any, T any](list []F, convert func(F) T) []T
- func ListLazy[F any, T any](convert func(F) T) func(list []F) []T
- func ToInt[T ~int](a T) int
- func ToStrings[T ~string](a []T) []string
- type Alias
- type ArrayLiteralType
- type ArrayType
- type Bindings
- func (b *Bindings) Alias(alias *Alias) (*goja.Object, error)
- func (b *Bindings) Array(arrType ExpressionType) (*goja.Object, error)
- func (b *Bindings) ArrayLiteral(value *ArrayLiteralType) (*goja.Object, error)
- func (b *Bindings) BooleanLiteral(value int) (*goja.Object, error)
- func (b *Bindings) Comment(comment Comment) (*goja.Object, error)
- func (b *Bindings) FloatLiteral(value float64) (*goja.Object, error)
- func (b *Bindings) HeritageClause(clause *HeritageClause) (*goja.Object, error)
- func (b *Bindings) Identifier(name string) (*goja.Object, error)
- func (b *Bindings) Interface(ti *Interface) (*goja.Object, error)
- func (b *Bindings) LiteralKeyword(word *LiteralKeyword) (*goja.Object, error)
- func (b *Bindings) Modifier(name Modifier) (*goja.Object, error)
- func (b *Bindings) Null() (*goja.Object, error)
- func (b *Bindings) NumericLiteral(value int64) (*goja.Object, error)
- func (b *Bindings) OperatorNode(value *OperatorNodeType) (*goja.Object, error)
- func (b *Bindings) PropertySignature(sig *PropertySignature) (*goja.Object, error)
- func (b *Bindings) Reference(ref *ReferenceType) (*goja.Object, error)
- func (b *Bindings) SerializeToTypescript(node *goja.Object) (string, error)
- func (b *Bindings) StringLiteral(value string) (*goja.Object, error)
- func (b *Bindings) ToTypescriptDeclarationNode(ety DeclarationType) (*goja.Object, error)
- func (b *Bindings) ToTypescriptExpressionNode(ety ExpressionType) (*goja.Object, error)
- func (b *Bindings) ToTypescriptNode(ety Node) (*goja.Object, error)
- func (b *Bindings) TypeParameter(ty *TypeParameter) (*goja.Object, error)
- func (b *Bindings) Union(ty *UnionType) (*goja.Object, error)
- func (b *Bindings) VariableDeclaration(decl *VariableDeclaration) (*goja.Object, error)
- func (b *Bindings) VariableDeclarationList(list *VariableDeclarationList) (*goja.Object, error)
- func (b *Bindings) VariableStatement(stmt *VariableStatement) (*goja.Object, error)
- type Comment
- type DeclarationType
- type ExpressionType
- type ExpressionWithTypeArguments
- type HeritageClause
- type HeritageType
- type Identifier
- type Interface
- type LiteralKeyword
- type LiteralType
- type Modifier
- type Node
- type NodeFlags
- type Null
- type OperatorNodeType
- type PropertySignature
- type ReferenceType
- type Source
- type TypeParameter
- type UnionType
- type VariableDeclaration
- type VariableDeclarationList
- type VariableStatement
Constants ¶
const ( ModifierAbstract = "AbstractKeyword" ModifierAccessor = "AccessorKeyword" ModifierAsync = "AsyncKeyword" ModifierConst = "ConstKeyword" ModifierDeclare = "DeclareKeyword" ModifierDefault = "DefaultKeyword" ModifierExport = "ExportKeyword" ModifierIn = "InKeyword" ModifierPrivate = "PrivateKeyword" ModifierProtected = "ProtectedKeyword" ModifierPublic = "PublicKeyword" ModifierReadonly = "ReadonlyKeyword" ModifierOut = "OutKeyword" ModifierOverride = "OverrideKeyword" ModifierStatic = "StaticKeyword" )
const (
NodeFlagsConstant = 2
)
Variables ¶
This section is empty.
Functions ¶
func List ¶
List is a helper function to reduce boilerplate when converting slices of database types to slices of codersdk types. Only works if the function takes a single argument.
Types ¶
type Alias ¶
type Alias struct { Name Identifier Modifiers []Modifier Type ExpressionType Parameters []*TypeParameter Source }
type ArrayLiteralType ¶
type ArrayLiteralType struct {
Elements []ExpressionType
}
func (ArrayLiteralType) String ¶
func (a ArrayLiteralType) String() string
type ArrayType ¶
type ArrayType struct {
Node ExpressionType
}
func Array ¶
func Array(node ExpressionType) *ArrayType
type Bindings ¶
type Bindings struct {
// contains filtered or unexported fields
}
func (*Bindings) ArrayLiteral ¶
func (b *Bindings) ArrayLiteral(value *ArrayLiteralType) (*goja.Object, error)
func (*Bindings) BooleanLiteral ¶
func (*Bindings) FloatLiteral ¶
func (*Bindings) HeritageClause ¶
func (b *Bindings) HeritageClause(clause *HeritageClause) (*goja.Object, error)
func (*Bindings) LiteralKeyword ¶
func (b *Bindings) LiteralKeyword(word *LiteralKeyword) (*goja.Object, error)
func (*Bindings) NumericLiteral ¶
func (*Bindings) OperatorNode ¶
func (b *Bindings) OperatorNode(value *OperatorNodeType) (*goja.Object, error)
func (*Bindings) PropertySignature ¶
func (b *Bindings) PropertySignature(sig *PropertySignature) (*goja.Object, error)
func (*Bindings) SerializeToTypescript ¶
func (*Bindings) StringLiteral ¶
func (*Bindings) ToTypescriptDeclarationNode ¶
func (b *Bindings) ToTypescriptDeclarationNode(ety DeclarationType) (*goja.Object, error)
func (*Bindings) ToTypescriptExpressionNode ¶
func (b *Bindings) ToTypescriptExpressionNode(ety ExpressionType) (*goja.Object, error)
func (*Bindings) ToTypescriptNode ¶
func (*Bindings) TypeParameter ¶
func (b *Bindings) TypeParameter(ty *TypeParameter) (*goja.Object, error)
func (*Bindings) VariableDeclaration ¶
func (b *Bindings) VariableDeclaration(decl *VariableDeclaration) (*goja.Object, error)
func (*Bindings) VariableDeclarationList ¶
func (b *Bindings) VariableDeclarationList(list *VariableDeclarationList) (*goja.Object, error)
func (*Bindings) VariableStatement ¶
func (b *Bindings) VariableStatement(stmt *VariableStatement) (*goja.Object, error)
type DeclarationType ¶
type DeclarationType interface { Node // contains filtered or unexported methods }
DeclarationType is any type that can exist at the top level of a AST. Meaning it can be serialized into valid Typescript.
type ExpressionType ¶
type ExpressionType interface { Node // contains filtered or unexported methods }
ExpressionType
type ExpressionWithTypeArguments ¶
type ExpressionWithTypeArguments struct { Expression ExpressionType Arguments []ExpressionType }
type HeritageClause ¶
type HeritageClause struct { Token HeritageType Args []ExpressionType }
HeritageClause interface Foo extends Bar, Baz {}
func HeritageClauseExtends ¶
func HeritageClauseExtends(args ...ExpressionType) *HeritageClause
type HeritageType ¶
type HeritageType string
const ( HeritageTypeExtends HeritageType = "extends" HeritageTypeImplements HeritageType = "implements" )
type Identifier ¶
Identifier is a name given to a variable, function, class, etc. Identifiers should be unique within a package. Package information is included to help with disambiguation in the case of name collisions.
func (Identifier) GoName ¶
func (i Identifier) GoName() string
GoName should be a unique name for the identifier across all Go packages.
func (Identifier) PkgName ¶
func (i Identifier) PkgName() string
func (Identifier) Ref ¶
func (i Identifier) Ref() string
Ref returns the identifier reference to be used in the generated code. This is the identifier to be used in typescript, since all generated code lands in the same namespace.
func (Identifier) String ¶
func (i Identifier) String() string
type Interface ¶
type Interface struct { Name Identifier Modifiers []Modifier Fields []*PropertySignature Parameters []*TypeParameter Heritage []*HeritageClause // Comments maybe should be its own AST node? Comments []string Source }
type LiteralKeyword ¶
type LiteralKeyword string
const ( KeywordVoid LiteralKeyword = "VoidKeyword" KeywordAny LiteralKeyword = "AnyKeyword" KeywordBoolean LiteralKeyword = "BooleanKeyword" KeywordIntrinsic LiteralKeyword = "IntrinsicKeyword" KeywordNever LiteralKeyword = "NeverKeyword" KeywordNumber LiteralKeyword = "NumberKeyword" KeywordObject LiteralKeyword = "ObjectKeyword" KeywordString LiteralKeyword = "StringKeyword" KeywordSymbol LiteralKeyword = "SymbolKeyword" KeywordUndefined LiteralKeyword = "UndefinedKeyword" KeywordUnknown LiteralKeyword = "UnknownKeyword" KeywordBigInt LiteralKeyword = "BigIntKeyword" KeywordReadonly LiteralKeyword = "ReadonlyKeyword" KeywordUnique LiteralKeyword = "UniqueKeyword" KeywordKeyOf LiteralKeyword = "KeyOfKeyword" )
func ToTypescriptLiteralKeyword ¶
func ToTypescriptLiteralKeyword(word string) (LiteralKeyword, error)
func (LiteralKeyword) String ¶
func (k LiteralKeyword) String() string
type LiteralType ¶
type LiteralType struct {
Value any // should be some constant value
}
type OperatorNodeType ¶
type OperatorNodeType struct { Keyword LiteralKeyword Type ExpressionType }
func OperatorNode ¶
func OperatorNode(keyword LiteralKeyword, node ExpressionType) *OperatorNodeType
OperatorNode allows adding a keyword to a type Keyword must be "KeyOfKeyword" | "UniqueKeyword" | "ReadonlyKeyword"
func (OperatorNodeType) String ¶
func (o OperatorNodeType) String() string
type PropertySignature ¶
type PropertySignature struct { // Name is the field name Name string Modifiers []Modifier QuestionToken bool Type ExpressionType // FieldComments maybe should be its own AST node? FieldComments []string }
PropertySignature is a field in an interface
func (PropertySignature) String ¶
func (f PropertySignature) String() string
type ReferenceType ¶
type ReferenceType struct { Name Identifier `json:"name"` // TODO: Generics Arguments []ExpressionType `json:"arguments"` }
ReferenceType can be used to reference another type by name
func Reference ¶
func Reference(name Identifier, args ...ExpressionType) *ReferenceType
func (ReferenceType) String ¶
func (r ReferenceType) String() string
type TypeParameter ¶
type TypeParameter struct { Name Identifier Modifiers []Modifier Type ExpressionType // DefaultType does not map to any Golang concepts and will never be // used. DefaultType ExpressionType }
TypeParameter are generics in Go Foo[T comparable] -> - name: T - Modifiers: [] - Type: Comparable - DefaultType: nil
func Simplify ¶
func Simplify(p []*TypeParameter) ([]*TypeParameter, error)
Simplify removes duplicate type parameters
func (TypeParameter) String ¶
func (p TypeParameter) String() string
type UnionType ¶
type UnionType struct {
Types []ExpressionType
}
func Union ¶
func Union(types ...ExpressionType) *UnionType
type VariableDeclaration ¶
type VariableDeclaration struct { Name Identifier ExclamationMark bool Type ExpressionType Initializer ExpressionType }
func (VariableDeclaration) String ¶
func (v VariableDeclaration) String() string
type VariableDeclarationList ¶
type VariableDeclarationList struct { Declarations []*VariableDeclaration Flags NodeFlags }
type VariableStatement ¶
type VariableStatement struct { Modifiers []Modifier Declarations *VariableDeclarationList Source }
VariableStatement is a top level declaration of a variable var foo: string = "bar" const foo: string = "bar"