tsimport

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRelativePathForRoot added in v0.2.0

func GetRelativePathForRoot(cfg Config, filePath string) string

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
	DebugMode() bool
}

type ImportPath added in v0.0.38

type ImportPath struct {
	ImportPath    string `json:"importPath"`
	Import        string `json:"import"`
	DefaultImport bool   `json:"defaultImport,omitempty"`
	// we name this originalImport so that clients everywhere can just keep calling useImport .Import
	OriginalImport string `json:"originalImport,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"`

	Class bool `json:"class,omitempty"`

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

	// automatically imported and we don't need to use it
	// imported as follows: `import "{path}";`
	SideEffect bool `json:"sideEffect"`

	// indicates this should be imported as a type-only import
	TypeOnly bool `json:"typeOnly,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 NewGQLClassImportPath added in v0.1.0

func NewGQLClassImportPath(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 NewGraphQLScalarsImportPath added in v0.1.8

func NewGraphQLScalarsImportPath(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

func NewLocalGraphQLInputEntImportPath added in v0.1.0

func NewLocalGraphQLInputEntImportPath(typ string) *ImportPath

func NewTypesEntImportPath added in v0.1.0

func NewTypesEntImportPath(typ string) *ImportPath

func (*ImportPath) Clone added in v0.3.2

func (ip *ImportPath) Clone() *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) ConditionallyReserveImportPath added in v0.1.0

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

ConditionallyReserveImportPath skips importing when the import path is same as file path

func (*Imports) ConditionallyReserveTypeImportPath added in v0.3.2

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

ConditionallyReserveTypeImportPath skips importing when the import path is same as file path and reserves the import as type-only.

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) ExportType added in v0.3.2

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

ExportType exports type-only bindings from a path.

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, imports ...string) (string, error)

Reserve reserves a path and list of imports

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, defaultImport string, imports ...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) ReserveType added in v0.3.2

func (imps *Imports) ReserveType(path string, imports ...string) (string, error)

ReserveType reserves a type-only import from a path.

func (*Imports) ReserveTypeImportPath added in v0.3.2

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

ReserveTypeImportPath takes an instance of importPath and reserves importing it as type-only.

func (*Imports) String

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

Returns a list of imported lines

func (*Imports) Use

func (imps *Imports) Use(impItem 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)

func (*Imports) UseType added in v0.3.2

func (imps *Imports) UseType(impItem string) (string, error)

UseType makes use of a type-only import and ensures it's imported

func (*Imports) UseTypeMaybe added in v0.3.2

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

UseTypeMaybe makes use of a type-only import if it exists.

Jump to

Keyboard shortcuts

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