tsImports

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TsImports

type TsImports []*tsImport

TsImports is a collection of single Typescript - TS line imports

func New

func New() *TsImports

New will just return a pointer to an empty TsImports

func (*TsImports) AddDefaultImport

func (i *TsImports) AddDefaultImport(defaultImport string, path string) error

AddDefaultImport will add a new default import for the given path

If the given path already has a default import, and it is not equal the given defaultImport param, an error will be returned, since a path can not contain more than one default import

If there's another default/named import with the name equal to the given defaultImport param, in the entire list of imports, an error will be returned, since an import name must be unique

If there's no error (return value == nil), the given defaultImport will never be changed inside the imports

func (*TsImports) AddNamedImport

func (i *TsImports) AddNamedImport(namedImport string, path string) error

AddNamedImport will add a new named import to the given path

If there's another default/named import with the name equal to the given namedImport, in the entire list of imports, an error will be returned, since an import name must be unique

If there's no error (return value == nil), the given namedImport will never be changed inside the imports

func (TsImports) SourceCode

func (i TsImports) SourceCode() string

SourceCode will return valid Typescript - TS code, for the stored imports, ready to be compiled

Jump to

Keyboard shortcuts

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