tsimport

package
v0.0.39-alpha1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImportPathEqual added in v0.0.38

func ImportPathEqual(ip1, ip2 *ImportPath) bool

func ImportPathsEqual added in v0.0.38

func ImportPathsEqual(l1, l2 []*ImportPath) bool

Types

type Config

type Config interface {
	GetAbsPathToRoot() string
	ShouldUseRelativePaths() bool
}

type ImportPath added in v0.0.38

type ImportPath struct {
	ImportPath    string `json:"importPath"`
	Import        string `json:"import"`
	DefaultImport bool   `json:"defaultImport,omitempty"`

	// only used in graphql (at least for now)
	// defaults to no. if function, call it instead of just referencing the import when used?
	Function bool `json:"function,omitempty"`

	TransformedForGraphQLMutation bool `json:"transformedForGraphQLMutation,omitempty"`
	TransformedForExternalEnt     bool `json:"transformedForExternalEnt,omitempty"`
}

func NewEntActionImportPath added in v0.0.38

func NewEntActionImportPath(typ string) *ImportPath

func NewEntGraphQLImportPath added in v0.0.38

func NewEntGraphQLImportPath(typ string) *ImportPath

func NewEntImportPath added in v0.0.38

func NewEntImportPath(typ string) *ImportPath

func NewGQLImportPath added in v0.0.38

func NewGQLImportPath(typ string) *ImportPath

NewGQLImportPath creates a new import from "graphql"

func NewGraphQLJSONImportPath added in v0.0.38

func NewGraphQLJSONImportPath(typ string) *ImportPath

func NewLocalEntConnectionImportPath added in v0.0.38

func NewLocalEntConnectionImportPath(typ string) *ImportPath

func NewLocalEntImportPath added in v0.0.38

func NewLocalEntImportPath(typ string) *ImportPath

func NewLocalGraphQLEntImportPath added in v0.0.38

func NewLocalGraphQLEntImportPath(typ string) *ImportPath

type Imports

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

Imports keeps track of imports in a generated typescript file

func NewImports

func NewImports(cfg Config, filePath string) *Imports

NewImports is the constructor for Imports filePath is path that's currently being written

func (*Imports) Export

func (imps *Imports) Export(path string, exports ...string) (string, error)

func (*Imports) ExportAll

func (imps *Imports) ExportAll(path string) (string, error)

func (*Imports) ExportAllAs

func (imps *Imports) ExportAllAs(path, as string) (string, error)

func (*Imports) FuncMap

func (imps *Imports) FuncMap() template.FuncMap

FuncMap returns the FuncMap to be passed to a template

func (*Imports) Reserve

func (imps *Imports) Reserve(path string, exports ...string) (string, error)

Reserve reserves a path and list of exports

func (*Imports) ReserveAll

func (imps *Imports) ReserveAll(path, as string) (string, error)

ReserveAll reserves importing all from a path as the alias

func (*Imports) ReserveDefault

func (imps *Imports) ReserveDefault(path, defaultExport string, exports ...string) (string, error)

ReserveDefault reserves the default export from a path and a list of exports

func (*Imports) ReserveImportPath added in v0.0.38

func (imps *Imports) ReserveImportPath(imp *ImportPath, external bool) (string, error)

ReserveImportPath takes an instance of importPath and reserves importing from it should be default eventually

func (*Imports) String

func (imps *Imports) String() (string, error)

Returns a list of imported lines

func (*Imports) Use

func (imps *Imports) Use(export string) (string, error)

Use makes use of an export and ensures that's imported

func (*Imports) UseMaybe

func (imps *Imports) UseMaybe(export string) (string, error)

Jump to

Keyboard shortcuts

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