core

package
v0.0.0-...-f2d955b Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResolutionModeNone     = ModuleKindNone
	ResolutionModeCommonJS = ModuleKindCommonJS
	ResolutionModeESM      = ModuleKindESNext
)

Variables

View Source
var ExclusivelyPrefixedNodeCoreModules = map[string]bool{
	"node:sea":            true,
	"node:sqlite":         true,
	"node:test":           true,
	"node:test/reporters": true,
}
View Source
var NodeCoreModules = sync.OnceValue(func() map[string]bool {
	nodeCoreModules := make(map[string]bool, len(UnprefixedNodeCoreModules)*2+len(ExclusivelyPrefixedNodeCoreModules))
	for unprefixed := range UnprefixedNodeCoreModules {
		nodeCoreModules[unprefixed] = true
		nodeCoreModules["node:"+unprefixed] = true
	}
	maps.Copy(nodeCoreModules, ExclusivelyPrefixedNodeCoreModules)
	return nodeCoreModules
})
View Source
var UnprefixedNodeCoreModules = map[string]bool{
	"assert":              true,
	"assert/strict":       true,
	"async_hooks":         true,
	"buffer":              true,
	"child_process":       true,
	"cluster":             true,
	"console":             true,
	"constants":           true,
	"crypto":              true,
	"dgram":               true,
	"diagnostics_channel": true,
	"dns":                 true,
	"dns/promises":        true,
	"domain":              true,
	"events":              true,
	"fs":                  true,
	"fs/promises":         true,
	"http":                true,
	"http2":               true,
	"https":               true,
	"inspector":           true,
	"inspector/promises":  true,
	"module":              true,
	"net":                 true,
	"os":                  true,
	"path":                true,
	"path/posix":          true,
	"path/win32":          true,
	"perf_hooks":          true,
	"process":             true,
	"punycode":            true,
	"querystring":         true,
	"readline":            true,
	"readline/promises":   true,
	"repl":                true,
	"stream":              true,
	"stream/consumers":    true,
	"stream/promises":     true,
	"stream/web":          true,
	"string_decoder":      true,
	"sys":                 true,
	"test/mock_loader":    true,
	"timers":              true,
	"timers/promises":     true,
	"tls":                 true,
	"trace_events":        true,
	"tty":                 true,
	"url":                 true,
	"util":                true,
	"util/types":          true,
	"v8":                  true,
	"vm":                  true,
	"wasi":                true,
	"worker_threads":      true,
	"zlib":                true,
}

Functions

func AppendIfUnique

func AppendIfUnique[T comparable](slice []T, element T) []T

func ApplyBulkEdits

func ApplyBulkEdits(text string, edits []TextChange) string

func BinarySearchUniqueFunc

func BinarySearchUniqueFunc[S ~[]E, E any](x S, cmp func(int, E) int) (int, bool)

BinarySearchUniqueFunc works like slices.BinarySearchFunc, but avoids extra invocations of the comparison function by assuming that only one element in the slice could match the target. Also, unlike slices.BinarySearchFunc, the comparison function is passed the current index of the element being compared, instead of the target element.

func CheckEachDefined

func CheckEachDefined[S any](s []*S, msg string) []*S

func Coalesce

func Coalesce[T *U, U any](a T, b T) T

Returns `a` if `a` is not `nil`; Otherwise, returns `b`. Coalesce is roughly analogous to `??` in JS, except that it non-shortcutting, so it is advised to only use a constant or precomputed value for `b`

func ComputeECMALineStartsSeq

func ComputeECMALineStartsSeq(text string) iter.Seq[TextPos]

func Concatenate

func Concatenate[T any](s1 []T, s2 []T) []T

func ConcatenateSeq

func ConcatenateSeq[T any](seqs ...iter.Seq[T]) iter.Seq[T]

func CopyMapInto

func CopyMapInto[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) map[K]V

CopyMapInto is maps.Copy, unless dst is nil, in which case it clones and returns src. Use CopyMapInto anywhere you would use maps.Copy preceded by a nil check and map initialization.

func CountWhere

func CountWhere[T any](slice []T, f func(T) bool) int

func Deduplicate

func Deduplicate[T comparable](slice []T) []T

func DiffMaps

func DiffMaps[K comparable, V comparable](m1 map[K]V, m2 map[K]V, onAdded func(K, V), onRemoved func(K, V), onChanged func(K, V, V))

func DiffMapsFunc

func DiffMapsFunc[K comparable, V any](m1 map[K]V, m2 map[K]V, equalValues func(V, V) bool, onAdded func(K, V), onRemoved func(K, V), onChanged func(K, V, V))

func ElementOrNil

func ElementOrNil[T any](slice []T, index int) T

func Every

func Every[T any](slice []T, f func(T) bool) bool

func Filter

func Filter[T any](slice []T, f func(T) bool) []T

func FilterIndex

func FilterIndex[T any](slice []T, f func(T, int, []T) bool) []T

func Find

func Find[T any](slice []T, f func(T) bool) T

func FindBestPatternMatch

func FindBestPatternMatch[T any](values []T, getPattern func(v T) Pattern, candidate string) T

func FindIndex

func FindIndex[T any](slice []T, f func(T) bool) int

func FindLast

func FindLast[T any](slice []T, f func(T) bool) T

func FindLastIndex

func FindLastIndex[T any](slice []T, f func(T) bool) int

func FirstNonNil

func FirstNonNil[T any, U comparable](slice []T, f func(T) U) U

func FirstOrNil

func FirstOrNil[T any](slice []T) T

func FirstOrNilSeq

func FirstOrNilSeq[T any](seq iter.Seq[T]) T

func FirstResult

func FirstResult[T1 any](t1 T1, _ ...any) T1

Extracts the first value of a multi-value return.

func FlatMap

func FlatMap[T any, U comparable](slice []T, f func(T) []U) []U

func Flatten

func Flatten[T any](array [][]T) []T

func GetLocale

func GetLocale(ctx context.Context) language.Tag

func GetRequestID

func GetRequestID(ctx context.Context) string

func GetSpellingSuggestion

func GetSpellingSuggestion[T any](name string, candidates []T, getName func(T) string) T

Given a name and a list of names that are *not* equal to the name, return a spelling suggestion if there is one that is close enough. Names less than length 3 only check for case-insensitive equality.

find the candidate with the smallest Levenshtein distance,

except for candidates:
  * With no name
  * Whose length differs from the target name by more than 0.34 of the length of the name.
  * Whose levenshtein distance is more than 0.4 of the length of the name
    (0.4 allows 1 substitution/transposition for every 5 characters,
     and 1 insertion/deletion at 3 characters)

@internal

func Identity

func Identity[T any](t T) T

func IfElse

func IfElse[T any](b bool, whenTrue T, whenFalse T) T

Returns whenTrue if b is true; otherwise, returns whenFalse. IfElse should only be used when branches are either constant or precomputed as both branches will be evaluated regardless as to the value of b.

func IndexAfter

func IndexAfter(s string, pattern string, startIndex int) int

func InsertSorted

func InsertSorted[T any](slice []T, element T, cmp func(T, T) int) []T

func LastOrNil

func LastOrNil[T any](slice []T) T

func Map

func Map[T, U any](slice []T, f func(T) U) []U

func MapFiltered

func MapFiltered[T any, U any](slice []T, f func(T) (U, bool)) []U

func MapIndex

func MapIndex[T, U any](slice []T, f func(T, int) U) []U

func MapNonNil

func MapNonNil[T any, U comparable](slice []T, f func(T) U) []U

func Memoize

func Memoize[T any](create func() T) func() T

func Must

func Must[T any](v T, err error) T

func NonRelativeModuleNameForTypingCache

func NonRelativeModuleNameForTypingCache(moduleName string) string

func Or

func Or[T any](funcs ...func(T) bool) func(T) bool

func OrElse

func OrElse[T comparable](value T, defaultValue T) T

Returns value if value is not the zero value of T; Otherwise, returns defaultValue. OrElse should only be used when defaultValue is constant or precomputed as its argument will be evaluated regardless as to the content of value.

func PositionToLineAndCharacter

func PositionToLineAndCharacter(position int, lineStarts []TextPos) (line int, character int)

func ReplaceElement

func ReplaceElement[T any](slice []T, i int, t T) []T

func ResolveConfigFileNameOfProjectReference

func ResolveConfigFileNameOfProjectReference(path string) string

func ResolveProjectReferencePath

func ResolveProjectReferencePath(ref *ProjectReference) string

func Same

func Same[T any](s1 []T, s2 []T) bool

func SameMap

func SameMap[T comparable](slice []T, f func(T) T) []T

func SameMapIndex

func SameMapIndex[T comparable](slice []T, f func(T, int) T) []T

func ShouldRewriteModuleSpecifier

func ShouldRewriteModuleSpecifier(specifier string, compilerOptions *CompilerOptions) bool

func SingleElementSlice

func SingleElementSlice[T any](element *T) []*T

func Some

func Some[T any](slice []T, f func(T) bool) bool

func Splice

func Splice[T any](s1 []T, start int, deleteCount int, items ...T) []T

func StringifyJson

func StringifyJson(input any, prefix string, indent string) (string, error)

func TryMap

func TryMap[T, U any](slice []T, f func(T) (U, error)) ([]U, error)

func Version

func Version() string

func VersionMajorMinor

func VersionMajorMinor() string

func WithLocale

func WithLocale(ctx context.Context, locale language.Tag) context.Context

func WithRequestID

func WithRequestID(ctx context.Context, id string) context.Context

Types

type BreadthFirstSearchLevel

type BreadthFirstSearchLevel[K comparable, N any] struct {
	// contains filtered or unexported fields
}

func (*BreadthFirstSearchLevel[K, N]) Delete

func (l *BreadthFirstSearchLevel[K, N]) Delete(key K)

func (*BreadthFirstSearchLevel[K, N]) Has

func (l *BreadthFirstSearchLevel[K, N]) Has(key K) bool

func (*BreadthFirstSearchLevel[K, N]) Range

func (l *BreadthFirstSearchLevel[K, N]) Range(f func(node N) bool)

type BreadthFirstSearchOptions

type BreadthFirstSearchOptions[K comparable, N any] struct {
	// Visited is a set of nodes that have already been visited.
	// If nil, a new set will be created.
	Visited *collections.SyncSet[K]
	// PreprocessLevel is a function that, if provided, will be called
	// before each level, giving the caller an opportunity to remove nodes.
	PreprocessLevel func(*BreadthFirstSearchLevel[K, N])
}

type BreadthFirstSearchResult

type BreadthFirstSearchResult[N any] struct {
	Stopped bool
	Path    []N
}

func BreadthFirstSearchParallel

func BreadthFirstSearchParallel[N comparable](
	start N,
	neighbors func(N) []N,
	visit func(node N) (isResult bool, stop bool),
) BreadthFirstSearchResult[N]

BreadthFirstSearchParallel performs a breadth-first search on a graph starting from the given node. It processes nodes in parallel and returns the path from the first node that satisfies the `visit` function back to the start node.

func BreadthFirstSearchParallelEx

func BreadthFirstSearchParallelEx[K comparable, N any](
	start N,
	neighbors func(N) []N,
	visit func(node N) (isResult bool, stop bool),
	options BreadthFirstSearchOptions[K, N],
	getKey func(N) K,
) BreadthFirstSearchResult[N]

BreadthFirstSearchParallelEx is an extension of BreadthFirstSearchParallel that allows the caller to pass a pre-seeded set of already-visited nodes and a preprocessing function that can be used to remove nodes from each level before parallel processing.

type BuildOptions

type BuildOptions struct {
	Dry               Tristate `json:"dry,omitzero"`
	Force             Tristate `json:"force,omitzero"`
	Verbose           Tristate `json:"verbose,omitzero"`
	StopBuildOnErrors Tristate `json:"stopBuildOnErrors,omitzero"`

	// Internal fields
	Clean Tristate `json:"clean,omitzero"`
	// contains filtered or unexported fields
}

type CompilerOptions

type CompilerOptions struct {
	AllowJs                                   Tristate                                  `json:"allowJs,omitzero"`
	AllowArbitraryExtensions                  Tristate                                  `json:"allowArbitraryExtensions,omitzero"`
	AllowSyntheticDefaultImports              Tristate                                  `json:"allowSyntheticDefaultImports,omitzero"`
	AllowImportingTsExtensions                Tristate                                  `json:"allowImportingTsExtensions,omitzero"`
	AllowNonTsExtensions                      Tristate                                  `json:"allowNonTsExtensions,omitzero"`
	AllowUmdGlobalAccess                      Tristate                                  `json:"allowUmdGlobalAccess,omitzero"`
	AllowUnreachableCode                      Tristate                                  `json:"allowUnreachableCode,omitzero"`
	AllowUnusedLabels                         Tristate                                  `json:"allowUnusedLabels,omitzero"`
	AssumeChangesOnlyAffectDirectDependencies Tristate                                  `json:"assumeChangesOnlyAffectDirectDependencies,omitzero"`
	AlwaysStrict                              Tristate                                  `json:"alwaysStrict,omitzero"`
	CheckJs                                   Tristate                                  `json:"checkJs,omitzero"`
	CustomConditions                          []string                                  `json:"customConditions,omitzero"`
	Composite                                 Tristate                                  `json:"composite,omitzero"`
	EmitDeclarationOnly                       Tristate                                  `json:"emitDeclarationOnly,omitzero"`
	EmitBOM                                   Tristate                                  `json:"emitBOM,omitzero"`
	EmitDecoratorMetadata                     Tristate                                  `json:"emitDecoratorMetadata,omitzero"`
	DownlevelIteration                        Tristate                                  `json:"downlevelIteration,omitzero"`
	Declaration                               Tristate                                  `json:"declaration,omitzero"`
	DeclarationDir                            string                                    `json:"declarationDir,omitzero"`
	DeclarationMap                            Tristate                                  `json:"declarationMap,omitzero"`
	DisableSizeLimit                          Tristate                                  `json:"disableSizeLimit,omitzero"`
	DisableSourceOfProjectReferenceRedirect   Tristate                                  `json:"disableSourceOfProjectReferenceRedirect,omitzero"`
	DisableSolutionSearching                  Tristate                                  `json:"disableSolutionSearching,omitzero"`
	DisableReferencedProjectLoad              Tristate                                  `json:"disableReferencedProjectLoad,omitzero"`
	ErasableSyntaxOnly                        Tristate                                  `json:"erasableSyntaxOnly,omitzero"`
	ESModuleInterop                           Tristate                                  `json:"esModuleInterop,omitzero"`
	ExactOptionalPropertyTypes                Tristate                                  `json:"exactOptionalPropertyTypes,omitzero"`
	ExperimentalDecorators                    Tristate                                  `json:"experimentalDecorators,omitzero"`
	ForceConsistentCasingInFileNames          Tristate                                  `json:"forceConsistentCasingInFileNames,omitzero"`
	IsolatedModules                           Tristate                                  `json:"isolatedModules,omitzero"`
	IsolatedDeclarations                      Tristate                                  `json:"isolatedDeclarations,omitzero"`
	IgnoreDeprecations                        string                                    `json:"ignoreDeprecations,omitzero"`
	ImportHelpers                             Tristate                                  `json:"importHelpers,omitzero"`
	InlineSourceMap                           Tristate                                  `json:"inlineSourceMap,omitzero"`
	InlineSources                             Tristate                                  `json:"inlineSources,omitzero"`
	Init                                      Tristate                                  `json:"init,omitzero"`
	Incremental                               Tristate                                  `json:"incremental,omitzero"`
	Jsx                                       JsxEmit                                   `json:"jsx,omitzero"`
	JsxFactory                                string                                    `json:"jsxFactory,omitzero"`
	JsxFragmentFactory                        string                                    `json:"jsxFragmentFactory,omitzero"`
	JsxImportSource                           string                                    `json:"jsxImportSource,omitzero"`
	Lib                                       []string                                  `json:"lib,omitzero"`
	LibReplacement                            Tristate                                  `json:"libReplacement,omitzero"`
	Locale                                    string                                    `json:"locale,omitzero"`
	MapRoot                                   string                                    `json:"mapRoot,omitzero"`
	Module                                    ModuleKind                                `json:"module,omitzero"`
	ModuleResolution                          ModuleResolutionKind                      `json:"moduleResolution,omitzero"`
	ModuleSuffixes                            []string                                  `json:"moduleSuffixes,omitzero"`
	ModuleDetection                           ModuleDetectionKind                       `json:"moduleDetection,omitzero"`
	NewLine                                   NewLineKind                               `json:"newLine,omitzero"`
	NoEmit                                    Tristate                                  `json:"noEmit,omitzero"`
	NoCheck                                   Tristate                                  `json:"noCheck,omitzero"`
	NoErrorTruncation                         Tristate                                  `json:"noErrorTruncation,omitzero"`
	NoFallthroughCasesInSwitch                Tristate                                  `json:"noFallthroughCasesInSwitch,omitzero"`
	NoImplicitAny                             Tristate                                  `json:"noImplicitAny,omitzero"`
	NoImplicitThis                            Tristate                                  `json:"noImplicitThis,omitzero"`
	NoImplicitReturns                         Tristate                                  `json:"noImplicitReturns,omitzero"`
	NoEmitHelpers                             Tristate                                  `json:"noEmitHelpers,omitzero"`
	NoLib                                     Tristate                                  `json:"noLib,omitzero"`
	NoPropertyAccessFromIndexSignature        Tristate                                  `json:"noPropertyAccessFromIndexSignature,omitzero"`
	NoUncheckedIndexedAccess                  Tristate                                  `json:"noUncheckedIndexedAccess,omitzero"`
	NoEmitOnError                             Tristate                                  `json:"noEmitOnError,omitzero"`
	NoUnusedLocals                            Tristate                                  `json:"noUnusedLocals,omitzero"`
	NoUnusedParameters                        Tristate                                  `json:"noUnusedParameters,omitzero"`
	NoResolve                                 Tristate                                  `json:"noResolve,omitzero"`
	NoImplicitOverride                        Tristate                                  `json:"noImplicitOverride,omitzero"`
	NoUncheckedSideEffectImports              Tristate                                  `json:"noUncheckedSideEffectImports,omitzero"`
	OutDir                                    string                                    `json:"outDir,omitzero"`
	Paths                                     *collections.OrderedMap[string, []string] `json:"paths,omitzero"`
	PreserveConstEnums                        Tristate                                  `json:"preserveConstEnums,omitzero"`
	PreserveSymlinks                          Tristate                                  `json:"preserveSymlinks,omitzero"`
	Project                                   string                                    `json:"project,omitzero"`
	ResolveJsonModule                         Tristate                                  `json:"resolveJsonModule,omitzero"`
	ResolvePackageJsonExports                 Tristate                                  `json:"resolvePackageJsonExports,omitzero"`
	ResolvePackageJsonImports                 Tristate                                  `json:"resolvePackageJsonImports,omitzero"`
	RemoveComments                            Tristate                                  `json:"removeComments,omitzero"`
	RewriteRelativeImportExtensions           Tristate                                  `json:"rewriteRelativeImportExtensions,omitzero"`
	ReactNamespace                            string                                    `json:"reactNamespace,omitzero"`
	RootDir                                   string                                    `json:"rootDir,omitzero"`
	RootDirs                                  []string                                  `json:"rootDirs,omitzero"`
	SkipLibCheck                              Tristate                                  `json:"skipLibCheck,omitzero"`
	Strict                                    Tristate                                  `json:"strict,omitzero"`
	StrictBindCallApply                       Tristate                                  `json:"strictBindCallApply,omitzero"`
	StrictBuiltinIteratorReturn               Tristate                                  `json:"strictBuiltinIteratorReturn,omitzero"`
	StrictFunctionTypes                       Tristate                                  `json:"strictFunctionTypes,omitzero"`
	StrictNullChecks                          Tristate                                  `json:"strictNullChecks,omitzero"`
	StrictPropertyInitialization              Tristate                                  `json:"strictPropertyInitialization,omitzero"`
	StripInternal                             Tristate                                  `json:"stripInternal,omitzero"`
	SkipDefaultLibCheck                       Tristate                                  `json:"skipDefaultLibCheck,omitzero"`
	SourceMap                                 Tristate                                  `json:"sourceMap,omitzero"`
	SourceRoot                                string                                    `json:"sourceRoot,omitzero"`
	SuppressOutputPathCheck                   Tristate                                  `json:"suppressOutputPathCheck,omitzero"`
	Target                                    ScriptTarget                              `json:"target,omitzero"`
	TraceResolution                           Tristate                                  `json:"traceResolution,omitzero"`
	TsBuildInfoFile                           string                                    `json:"tsBuildInfoFile,omitzero"`
	TypeRoots                                 []string                                  `json:"typeRoots,omitzero"`
	Types                                     []string                                  `json:"types,omitzero"`
	UseDefineForClassFields                   Tristate                                  `json:"useDefineForClassFields,omitzero"`
	UseUnknownInCatchVariables                Tristate                                  `json:"useUnknownInCatchVariables,omitzero"`
	VerbatimModuleSyntax                      Tristate                                  `json:"verbatimModuleSyntax,omitzero"`
	MaxNodeModuleJsDepth                      *int                                      `json:"maxNodeModuleJsDepth,omitzero"`

	// Deprecated: Do not use outside of options parsing and validation.
	BaseUrl string `json:"baseUrl,omitzero"`
	// Deprecated: Do not use outside of options parsing and validation.
	OutFile string `json:"outFile,omitzero"`

	// Internal fields
	ConfigFilePath      string   `json:"configFilePath,omitzero"`
	NoDtsResolution     Tristate `json:"noDtsResolution,omitzero"`
	PathsBasePath       string   `json:"pathsBasePath,omitzero"`
	Diagnostics         Tristate `json:"diagnostics,omitzero"`
	ExtendedDiagnostics Tristate `json:"extendedDiagnostics,omitzero"`
	GenerateCpuProfile  string   `json:"generateCpuProfile,omitzero"`
	GenerateTrace       string   `json:"generateTrace,omitzero"`
	ListEmittedFiles    Tristate `json:"listEmittedFiles,omitzero"`
	ListFiles           Tristate `json:"listFiles,omitzero"`
	ExplainFiles        Tristate `json:"explainFiles,omitzero"`
	ListFilesOnly       Tristate `json:"listFilesOnly,omitzero"`
	NoEmitForJsFiles    Tristate `json:"noEmitForJsFiles,omitzero"`
	PreserveWatchOutput Tristate `json:"preserveWatchOutput,omitzero"`
	Pretty              Tristate `json:"pretty,omitzero"`
	Version             Tristate `json:"version,omitzero"`
	Watch               Tristate `json:"watch,omitzero"`
	ShowConfig          Tristate `json:"showConfig,omitzero"`
	Build               Tristate `json:"build,omitzero"`
	Help                Tristate `json:"help,omitzero"`
	All                 Tristate `json:"all,omitzero"`

	PprofDir       string   `json:"pprofDir,omitzero"`
	SingleThreaded Tristate `json:"singleThreaded,omitzero"`
	Quiet          Tristate `json:"quiet,omitzero"`
	// contains filtered or unexported fields
}

func (*CompilerOptions) AllowImportingTsExtensionsFrom

func (options *CompilerOptions) AllowImportingTsExtensionsFrom(fileName string) bool

func (*CompilerOptions) Clone

func (options *CompilerOptions) Clone() *CompilerOptions

Clone creates a shallow copy of the CompilerOptions.

func (*CompilerOptions) GetAllowImportingTsExtensions

func (options *CompilerOptions) GetAllowImportingTsExtensions() bool

func (*CompilerOptions) GetAllowJS

func (options *CompilerOptions) GetAllowJS() bool

func (*CompilerOptions) GetAllowSyntheticDefaultImports

func (options *CompilerOptions) GetAllowSyntheticDefaultImports() bool

func (*CompilerOptions) GetAreDeclarationMapsEnabled

func (options *CompilerOptions) GetAreDeclarationMapsEnabled() bool

func (*CompilerOptions) GetESModuleInterop

func (options *CompilerOptions) GetESModuleInterop() bool

func (*CompilerOptions) GetEffectiveTypeRoots

func (options *CompilerOptions) GetEffectiveTypeRoots(currentDirectory string) (result []string, fromConfig bool)

func (*CompilerOptions) GetEmitDeclarations

func (options *CompilerOptions) GetEmitDeclarations() bool

func (*CompilerOptions) GetEmitModuleDetectionKind

func (options *CompilerOptions) GetEmitModuleDetectionKind() ModuleDetectionKind

func (*CompilerOptions) GetEmitModuleKind

func (options *CompilerOptions) GetEmitModuleKind() ModuleKind

func (*CompilerOptions) GetEmitScriptTarget

func (options *CompilerOptions) GetEmitScriptTarget() ScriptTarget

func (*CompilerOptions) GetEmitStandardClassFields

func (options *CompilerOptions) GetEmitStandardClassFields() bool

func (*CompilerOptions) GetIsolatedModules

func (options *CompilerOptions) GetIsolatedModules() bool

func (*CompilerOptions) GetJSXTransformEnabled

func (options *CompilerOptions) GetJSXTransformEnabled() bool

func (*CompilerOptions) GetModuleResolutionKind

func (options *CompilerOptions) GetModuleResolutionKind() ModuleResolutionKind

func (*CompilerOptions) GetPathsBasePath

func (options *CompilerOptions) GetPathsBasePath(currentDirectory string) string

func (*CompilerOptions) GetResolveJsonModule

func (options *CompilerOptions) GetResolveJsonModule() bool

func (*CompilerOptions) GetResolvePackageJsonExports

func (options *CompilerOptions) GetResolvePackageJsonExports() bool

func (*CompilerOptions) GetResolvePackageJsonImports

func (options *CompilerOptions) GetResolvePackageJsonImports() bool

func (*CompilerOptions) GetStrictOptionValue

func (options *CompilerOptions) GetStrictOptionValue(value Tristate) bool

func (*CompilerOptions) HasJsonModuleEmitEnabled

func (options *CompilerOptions) HasJsonModuleEmitEnabled() bool

func (*CompilerOptions) IsIncremental

func (options *CompilerOptions) IsIncremental() bool

func (*CompilerOptions) ShouldPreserveConstEnums

func (options *CompilerOptions) ShouldPreserveConstEnums() bool

func (*CompilerOptions) SourceFileAffecting

func (options *CompilerOptions) SourceFileAffecting() SourceFileAffectingCompilerOptions

type JsxEmit

type JsxEmit int32
const (
	JsxEmitNone        JsxEmit = 0
	JsxEmitPreserve    JsxEmit = 1
	JsxEmitReactNative JsxEmit = 2
	JsxEmitReact       JsxEmit = 3
	JsxEmitReactJSX    JsxEmit = 4
	JsxEmitReactJSXDev JsxEmit = 5
)

type LanguageVariant

type LanguageVariant int32
const (
	LanguageVariantStandard LanguageVariant = iota
	LanguageVariantJSX
)

func (LanguageVariant) String

func (i LanguageVariant) String() string

type LinkStore

type LinkStore[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func (*LinkStore[K, V]) Get

func (s *LinkStore[K, V]) Get(key K) *V

func (*LinkStore[K, V]) Has

func (s *LinkStore[K, V]) Has(key K) bool

func (*LinkStore[K, V]) TryGet

func (s *LinkStore[K, V]) TryGet(key K) *V

type ModuleDetectionKind

type ModuleDetectionKind int32
const (
	ModuleDetectionKindNone   ModuleDetectionKind = 0
	ModuleDetectionKindAuto   ModuleDetectionKind = 1
	ModuleDetectionKindLegacy ModuleDetectionKind = 2
	ModuleDetectionKindForce  ModuleDetectionKind = 3
)

type ModuleKind

type ModuleKind int32
const (
	ModuleKindNone     ModuleKind = 0
	ModuleKindCommonJS ModuleKind = 1
	// Deprecated: Do not use outside of options parsing and validation.
	ModuleKindAMD ModuleKind = 2
	// Deprecated: Do not use outside of options parsing and validation.
	ModuleKindUMD ModuleKind = 3
	// Deprecated: Do not use outside of options parsing and validation.
	ModuleKindSystem ModuleKind = 4
	// NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind.
	//       Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES
	//       module kind).
	ModuleKindES2015 ModuleKind = 5
	ModuleKindES2020 ModuleKind = 6
	ModuleKindES2022 ModuleKind = 7
	ModuleKindESNext ModuleKind = 99
	// Node16+ is an amalgam of commonjs (albeit updated) and es2022+, and represents a distinct module system from es2020/esnext
	ModuleKindNode16   ModuleKind = 100
	ModuleKindNode18   ModuleKind = 101
	ModuleKindNode20   ModuleKind = 102
	ModuleKindNodeNext ModuleKind = 199
	// Emit as written
	ModuleKindPreserve ModuleKind = 200
)

func (ModuleKind) IsNonNodeESM

func (moduleKind ModuleKind) IsNonNodeESM() bool

func (ModuleKind) String

func (i ModuleKind) String() string

func (ModuleKind) SupportsImportAttributes

func (moduleKind ModuleKind) SupportsImportAttributes() bool

type ModuleResolutionKind

type ModuleResolutionKind int32
const (
	ModuleResolutionKindUnknown ModuleResolutionKind = 0
	// Starting with node16, node's module resolver has significant departures from traditional cjs resolution
	// to better support ECMAScript modules and their use within node - however more features are still being added.
	// TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable
	// version that supports both pattern trailers - *but*, Node 16 is the first version that also supports ECMAScript 2022.
	// In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target
	ModuleResolutionKindNode16   ModuleResolutionKind = 3
	ModuleResolutionKindNodeNext ModuleResolutionKind = 99 // Not simply `Node16` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`)
	ModuleResolutionKindBundler  ModuleResolutionKind = 100
)

func (ModuleResolutionKind) String

func (m ModuleResolutionKind) String() string

We don't use stringer on this for now, because these values are user-facing in --traceResolution, and stringer currently lacks the ability to remove the "ModuleResolutionKind" prefix when generating code for multiple types into the same output file. Additionally, since there's no TS equivalent of `ModuleResolutionKindUnknown`, we want to panic on that case, as it probably represents a mistake when porting TS to Go.

type NewLineKind

type NewLineKind int32
const (
	NewLineKindNone NewLineKind = 0
	NewLineKindCRLF NewLineKind = 1
	NewLineKindLF   NewLineKind = 2
)

func GetNewLineKind

func GetNewLineKind(s string) NewLineKind

func (NewLineKind) GetNewLineCharacter

func (newLine NewLineKind) GetNewLineCharacter() string

type ParsedOptions

type ParsedOptions struct {
	CompilerOptions *CompilerOptions `json:"compilerOptions"`
	WatchOptions    *WatchOptions    `json:"watchOptions"`
	TypeAcquisition *TypeAcquisition `json:"typeAcquisition"`

	FileNames         []string            `json:"fileNames"`
	ProjectReferences []*ProjectReference `json:"projectReferences"`
}

type Pattern

type Pattern struct {
	Text      string
	StarIndex int // -1 for exact match
}

func TryParsePattern

func TryParsePattern(pattern string) Pattern

func (*Pattern) IsValid

func (p *Pattern) IsValid() bool

func (*Pattern) MatchedText

func (p *Pattern) MatchedText(candidate string) string

func (*Pattern) Matches

func (p *Pattern) Matches(candidate string) bool

type PollingKind

type PollingKind int32
const (
	PollingKindNone             PollingKind = 0
	PollingKindFixedInterval    PollingKind = 1
	PollingKindPriorityInterval PollingKind = 2
	PollingKindDynamicPriority  PollingKind = 3
	PollingKindFixedChunkSize   PollingKind = 4
)

type Pool

type Pool[T any] struct {
	// contains filtered or unexported fields
}

func (*Pool[T]) Clone

func (p *Pool[T]) Clone(t []T) []T

func (*Pool[T]) New

func (p *Pool[T]) New() *T

Allocate a single element in the pool and return a pointer to the element. If the pool is at capacity, a new pool of the next size up is allocated.

func (*Pool[T]) NewSlice

func (p *Pool[T]) NewSlice(size int) []T

Allocate a slice of the given size in the pool. If the requested size is beyond the capacity of the pool and a pool of the next size up still wouldn't fit the slice, make a separate memory allocation for the slice. Otherwise, grow the pool if necessary and allocate a slice out of it. The length and capacity of the resulting slice are equal to the given size.

func (*Pool[T]) NewSlice1

func (p *Pool[T]) NewSlice1(t T) []T

type ProjectReference

type ProjectReference struct {
	Path         string
	OriginalPath string
	Circular     bool
}

type ResolutionMode

type ResolutionMode = ModuleKind // ModuleKindNone | ModuleKindCommonJS | ModuleKindESNext

type ScriptKind

type ScriptKind int32
const (
	ScriptKindUnknown ScriptKind = iota
	ScriptKindJS
	ScriptKindJSX
	ScriptKindTS
	ScriptKindTSX
	ScriptKindExternal
	ScriptKindJSON
	/**
	 * Used on extensions that doesn't define the ScriptKind but the content defines it.
	 * Deferred extensions are going to be included in all project contexts.
	 */
	ScriptKindDeferred
)

func GetScriptKindFromFileName

func GetScriptKindFromFileName(fileName string) ScriptKind

func (ScriptKind) String

func (i ScriptKind) String() string

type ScriptTarget

type ScriptTarget int32
const (
	ScriptTargetNone   ScriptTarget = 0
	ScriptTargetES3    ScriptTarget = 0 // Deprecated
	ScriptTargetES5    ScriptTarget = 1
	ScriptTargetES2015 ScriptTarget = 2
	ScriptTargetES2016 ScriptTarget = 3
	ScriptTargetES2017 ScriptTarget = 4
	ScriptTargetES2018 ScriptTarget = 5
	ScriptTargetES2019 ScriptTarget = 6
	ScriptTargetES2020 ScriptTarget = 7
	ScriptTargetES2021 ScriptTarget = 8
	ScriptTargetES2022 ScriptTarget = 9
	ScriptTargetES2023 ScriptTarget = 10
	ScriptTargetES2024 ScriptTarget = 11
	ScriptTargetESNext ScriptTarget = 99
	ScriptTargetJSON   ScriptTarget = 100
	ScriptTargetLatest ScriptTarget = ScriptTargetESNext
)

func (ScriptTarget) String

func (i ScriptTarget) String() string

type SourceFileAffectingCompilerOptions

type SourceFileAffectingCompilerOptions struct {
	AllowUnreachableCode     Tristate
	AllowUnusedLabels        Tristate
	BindInStrictMode         bool
	ShouldPreserveConstEnums bool
}

SourceFileAffectingCompilerOptions are the precomputed CompilerOptions values which affect the parse and bind of a source file.

type Stack

type Stack[T any] struct {
	// contains filtered or unexported fields
}

func (*Stack[T]) Len

func (s *Stack[T]) Len() int

func (*Stack[T]) Peek

func (s *Stack[T]) Peek() T

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() T

func (*Stack[T]) Push

func (s *Stack[T]) Push(item T)

type TextChange

type TextChange struct {
	TextRange
	NewText string
}

func (TextChange) ApplyTo

func (t TextChange) ApplyTo(text string) string

type TextPos

type TextPos int32

func ComputeECMALineStarts

func ComputeECMALineStarts(text string) []TextPos

type TextRange

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

func NewTextRange

func NewTextRange(pos int, end int) TextRange

func UndefinedTextRange

func UndefinedTextRange() TextRange

func (TextRange) ContainedBy

func (t TextRange) ContainedBy(t2 TextRange) bool

func (TextRange) Contains

func (t TextRange) Contains(pos int) bool

func (TextRange) ContainsExclusive

func (t TextRange) ContainsExclusive(pos int) bool

func (TextRange) ContainsInclusive

func (t TextRange) ContainsInclusive(pos int) bool

func (TextRange) End

func (t TextRange) End() int

func (TextRange) IsValid

func (t TextRange) IsValid() bool

func (TextRange) Len

func (t TextRange) Len() int

func (TextRange) Overlaps

func (t TextRange) Overlaps(t2 TextRange) bool

func (TextRange) Pos

func (t TextRange) Pos() int

func (TextRange) WithEnd

func (t TextRange) WithEnd(end int) TextRange

func (TextRange) WithPos

func (t TextRange) WithPos(pos int) TextRange

type ThrottleGroup

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

ThrottleGroup is like errgroup.Group but with global concurrency limiting via a semaphore.

func NewThrottleGroup

func NewThrottleGroup(ctx context.Context, semaphore chan struct{}) *ThrottleGroup

NewThrottleGroup creates a new ThrottleGroup with the given context and semaphore for concurrency limiting.

func (*ThrottleGroup) Go

func (tg *ThrottleGroup) Go(fn func() error)

Go runs the given function in a new goroutine, but first acquires a slot from the semaphore. The semaphore slot is released when the function completes.

func (*ThrottleGroup) Wait

func (tg *ThrottleGroup) Wait() error

Wait waits for all goroutines to complete and returns the first error encountered, if any.

type Tristate

type Tristate byte
const (
	TSUnknown Tristate = iota
	TSFalse
	TSTrue
)

func BoolToTristate

func BoolToTristate(b bool) Tristate

func (Tristate) DefaultIfUnknown

func (t Tristate) DefaultIfUnknown(value Tristate) Tristate

func (Tristate) IsFalse

func (t Tristate) IsFalse() bool

func (Tristate) IsFalseOrUnknown

func (t Tristate) IsFalseOrUnknown() bool

func (Tristate) IsTrue

func (t Tristate) IsTrue() bool

func (Tristate) IsTrueOrUnknown

func (t Tristate) IsTrueOrUnknown() bool

func (Tristate) IsUnknown

func (t Tristate) IsUnknown() bool

func (Tristate) MarshalJSON

func (t Tristate) MarshalJSON() ([]byte, error)

func (Tristate) String

func (i Tristate) String() string

func (*Tristate) UnmarshalJSON

func (t *Tristate) UnmarshalJSON(data []byte) error

type TypeAcquisition

type TypeAcquisition struct {
	Enable                              Tristate `json:"enable,omitzero"`
	Include                             []string `json:"include,omitzero"`
	Exclude                             []string `json:"exclude,omitzero"`
	DisableFilenameBasedTypeAcquisition Tristate `json:"disableFilenameBasedTypeAcquisition,omitzero"`
}

func (*TypeAcquisition) Equals

func (ta *TypeAcquisition) Equals(other *TypeAcquisition) bool

type WatchDirectoryKind

type WatchDirectoryKind int32
const (
	WatchDirectoryKindNone                   WatchDirectoryKind = 0
	WatchDirectoryKindUseFsEvents            WatchDirectoryKind = 1
	WatchDirectoryKindFixedPollingInterval   WatchDirectoryKind = 2
	WatchDirectoryKindDynamicPriorityPolling WatchDirectoryKind = 3
	WatchDirectoryKindFixedChunkSizePolling  WatchDirectoryKind = 4
)

type WatchFileKind

type WatchFileKind int32
const (
	WatchFileKindNone                         WatchFileKind = 0
	WatchFileKindFixedPollingInterval         WatchFileKind = 1
	WatchFileKindPriorityPollingInterval      WatchFileKind = 2
	WatchFileKindDynamicPriorityPolling       WatchFileKind = 3
	WatchFileKindFixedChunkSizePolling        WatchFileKind = 4
	WatchFileKindUseFsEvents                  WatchFileKind = 5
	WatchFileKindUseFsEventsOnParentDirectory WatchFileKind = 6
)

type WatchOptions

type WatchOptions struct {
	Interval        *int               `json:"watchInterval"`
	FileKind        WatchFileKind      `json:"watchFile"`
	DirectoryKind   WatchDirectoryKind `json:"watchDirectory"`
	FallbackPolling PollingKind        `json:"fallbackPolling"`
	SyncWatchDir    Tristate           `json:"synchronousWatchDirectory"`
	ExcludeDir      []string           `json:"excludeDirectories"`
	ExcludeFiles    []string           `json:"excludeFiles"`
}

func (*WatchOptions) WatchInterval

func (w *WatchOptions) WatchInterval() time.Duration

type WorkGroup

type WorkGroup interface {
	// Queue queues a function to run. It may be invoked immediately, or deferred until RunAndWait.
	// It is not safe to call Queue after RunAndWait has returned.
	Queue(fn func())

	// RunAndWait runs all queued functions, blocking until they have all completed.
	RunAndWait()
}

func NewWorkGroup

func NewWorkGroup(singleThreaded bool) WorkGroup

Jump to

Keyboard shortcuts

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