Documentation
¶
Overview ¶
Package compiler implements the TypeScript compiler.
Index ¶
- func ContentMapperInitializationDiagnostic(label string, err error) *ast.Diagnostic
- func ContentMapperProjectDiagnostic(err error) *ast.Diagnostic
- func ContentMapperProjectErrorDiagnostic(err error) *diagnostics.Message
- func FilterNoEmitSemanticDiagnostics(diagnostics []*ast.Diagnostic, options *core.CompilerOptions) []*ast.Diagnostic
- func GetDiagnosticsOfAnyProgram(ctx context.Context, program ProgramLike, files []*ast.SourceFile, ...) []*ast.Diagnostic
- func SortAndDeduplicateDiagnostics(diagnostics []*ast.Diagnostic) []*ast.Diagnostic
- type CheckerPool
- type CompilerHost
- type DuplicateSourceFile
- type EmitHost
- type EmitOnly
- type EmitOptions
- type EmitResult
- type FileIncludeReason
- type LibFile
- type Program
- func (p *Program) BaseDirectory() tspath.RootedDirectoryPath
- func (p *Program) BindSourceFiles()
- func (p *Program) CaseSensitivity() tspath.CaseSensitivity
- func (p *Program) CommandLine() *tsoptions.ParsedCommandLine
- func (p *Program) CommonSourceDirectory() tspath.RootedDirectoryPath
- func (p *Program) ContentMapperExtensions() []string
- func (p *Program) ContentMapperProject() contentmapper.Project
- func (p *Program) DeepImportPackageNames() *collections.Set[string]
- func (p *Program) DuplicateSourceFiles() []*DuplicateSourceFile
- func (p *Program) Emit(ctx context.Context, options EmitOptions) *EmitResult
- func (p *Program) ExplainFiles(w io.Writer, locale locale.Locale, currentDirectory tspath.RootedDirectoryPath)
- func (p *Program) FileExists(path tspath.RootedFilePath) bool
- func (p *Program) FilesByPath() map[tspath.PathKey]*ast.SourceFile
- func (p *Program) ForEachCheckerParallel(cb func(idx int, c *checker.Checker))
- func (p *Program) ForEachResolvedModule(...)
- func (p *Program) ForEachResolvedTypeReferenceDirective(...)
- func (p *Program) GetBindDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic
- func (p *Program) GetCheckerPool() CheckerPool
- func (p *Program) GetConfigFileParsingDiagnostics() []*ast.Diagnostic
- func (p *Program) GetContentMapper(file *ast.SourceFile) *contentmapper.Mapper
- func (p *Program) GetCurrentDirectory() tspath.RootedDirectoryPath
- func (p *Program) GetDeclarationDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic
- func (p *Program) GetDefaultLibFile(path tspath.PathKey) *LibFile
- func (p *Program) GetDefaultResolutionModeForFile(sourceFile ast.HasFileName) core.ResolutionMode
- func (p *Program) GetEmitModuleFormatOfFile(sourceFile ast.HasFileName) core.ModuleKind
- func (p *Program) GetEmitSyntaxForUsageLocation(sourceFile ast.HasFileName, location *ast.StringLiteralLike) core.ResolutionMode
- func (p *Program) GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic
- func (p *Program) GetGlobalTypingsCacheLocation() tspath.RootedDirectoryPath
- func (p *Program) GetImpliedNodeFormatForEmit(sourceFile ast.HasFileName) core.ResolutionMode
- func (p *Program) GetImportHelpersImportSpecifier(path tspath.PathKey) *ast.Node
- func (p *Program) GetIncludeProcessorDiagnostics(sourceFile *ast.SourceFile) []*ast.Diagnostic
- func (p *Program) GetIncludeReasons() map[tspath.PathKey][]*FileIncludeReason
- func (p *Program) GetJSXRuntimeImportSpecifier(path tspath.PathKey) (moduleReference string, specifier *ast.Node)
- func (p *Program) GetLibFileFromReference(ref *ast.FileReference) *ast.SourceFile
- func (p *Program) GetModeForResolutionAtIndex(sourceFile *ast.SourceFile, index int) core.ResolutionMode
- func (p *Program) GetModeForUsageLocation(sourceFile ast.HasFileName, location *ast.StringLiteralLike) core.ResolutionMode
- func (p *Program) GetNearestAncestorDirectoryWithPackageJson(dirname tspath.RootedDirectoryPath) tspath.RootedDirectoryPath
- func (p *Program) GetPackageJsonInfo(pkgJsonPath tspath.RootedFilePath) *packagejson.InfoCacheEntry
- func (p *Program) GetPackagesMap() map[string]bool
- func (p *Program) GetParseFileRedirect(fileName tspath.RootedFilePath) tspath.RootedFilePath
- func (p *Program) GetProgramDiagnostics() []*ast.Diagnostic
- func (p *Program) GetProjectReferenceFromOutputDts(path tspath.PathKey) *tsoptions.SourceOutputAndProjectReference
- func (p *Program) GetProjectReferenceFromSource(path tspath.PathKey) *tsoptions.SourceOutputAndProjectReference
- func (p *Program) GetRedirectForResolution(file ast.HasFileName) *tsoptions.ParsedCommandLine
- func (p *Program) GetRedirectTargets(path tspath.PathKey) []tspath.RootedFilePath
- func (p *Program) GetResolvedModule(file ast.HasFileName, moduleReference string, mode core.ResolutionMode) *module.ResolvedModule
- func (p *Program) GetResolvedModuleFromModuleSpecifier(file ast.HasFileName, moduleSpecifier *ast.StringLiteralLike) *module.ResolvedModule
- func (p *Program) GetResolvedModules() map[tspath.PathKey]module.ModeAwareCache[*module.ResolvedModule]
- func (p *Program) GetResolvedProjectReferenceFor(path tspath.PathKey) (*tsoptions.ParsedCommandLine, bool)
- func (p *Program) GetResolvedProjectReferences() []*tsoptions.ParsedCommandLine
- func (p *Program) GetResolvedTypeReferenceDirective(file ast.HasFileName, typeDirectiveName string, mode core.ResolutionMode) *module.ResolvedTypeReferenceDirective
- func (p *Program) GetResolvedTypeReferenceDirectiveFromTypeReferenceDirective(typeRef *ast.FileReference, sourceFile *ast.SourceFile) *module.ResolvedTypeReferenceDirective
- func (p *Program) GetResolvedTypeReferenceDirectives() ...
- func (p *Program) GetSemanticDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic
- func (p *Program) GetSemanticDiagnosticsForIncremental(ctx context.Context, sourceFiles []*ast.SourceFile) map[*ast.SourceFile][]*ast.Diagnostic
- func (p *Program) GetSourceFile(fileName tspath.RootedFilePath) *ast.SourceFile
- func (p *Program) GetSourceFileByPath(path tspath.PathKey) *ast.SourceFile
- func (p *Program) GetSourceFileForResolvedModule(resolved *module.ResolvedModule) *ast.SourceFile
- func (p *Program) GetSourceFileFromReference(origin *ast.SourceFile, ref *ast.FileReference) *ast.SourceFile
- func (p *Program) GetSourceFileMetaData(path tspath.PathKey) ast.SourceFileMetaData
- func (p *Program) GetSourceFiles() []*ast.SourceFile
- func (p *Program) GetSourceOfProjectReferenceIfOutputIncluded(file ast.HasFileName) tspath.RootedFilePath
- func (p *Program) GetSuggestionDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic
- func (p *Program) GetSymlinkCache() *symlinks.KnownSymlinks
- func (p *Program) GetSyntacticDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic
- func (p *Program) GetTypeChecker(ctx context.Context) (*checker.Checker, func())
- func (p *Program) GetTypeCheckerForFile(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func())
- func (p *Program) GetTypeCheckerForFileExclusive(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func())
- func (p *Program) GetUnresolvedImports() *collections.Set[string]
- func (p *Program) HasSameFileNames(other *Program) bool
- func (p *Program) HasTSFile() bool
- func (p *Program) Host() CompilerHost
- func (p *Program) IdentifierCount() int
- func (p *Program) InstantiationCount() int
- func (p *Program) IsEmitBlocked(emitFileName tspath.RootedFilePath) bool
- func (p *Program) IsGlobalTypingsFile(fileName tspath.RootedFilePath) bool
- func (p *Program) IsLibFile(sourceFile *ast.SourceFile) bool
- func (p *Program) IsMissingPath(path tspath.PathKey) bool
- func (p *Program) IsSourceFileDefaultLibrary(path tspath.PathKey) bool
- func (p *Program) IsSourceFileFromExternalLibrary(file *ast.SourceFile) bool
- func (p *Program) IsSourceFromProjectReference(path tspath.PathKey) bool
- func (p *Program) LineCount() int
- func (p *Program) ModuleResolutionError() error
- func (p *Program) Options() *core.CompilerOptions
- func (p *Program) PackageJsonCacheEntries(f func(key tspath.PathKey, value *packagejson.InfoCacheEntry) bool)
- func (p *Program) PathKeyForFileName(fileName tspath.RootedFilePath) tspath.PathKey
- func (p *Program) Program() *Program
- func (p *Program) RangeResolvedProjectReference(f func(path tspath.PathKey, config *tsoptions.ParsedCommandLine, ...) bool) bool
- func (p *Program) RangeResolvedProjectReferenceInChildConfig(childConfig *tsoptions.ParsedCommandLine, ...) bool
- func (p *Program) ResolvedPackageNames() *collections.Set[string]
- func (p *Program) ReuseProgram(changedFilePath tspath.PathKey, newHost CompilerHost, ...) (*Program, *ast.SourceFile, bool)
- func (p *Program) SingleThreaded() bool
- func (p *Program) SkipTypeChecking(sourceFile *ast.SourceFile, ignoreNoCheck bool) bool
- func (p *Program) SourceFileMayBeEmitted(sourceFile *ast.SourceFile, forceDtsEmit bool) bool
- func (p *Program) SourceFiles() []*ast.SourceFile
- func (p *Program) SymbolCount() int
- func (p *Program) Tracing() *tracing.Tracing
- func (p *Program) TypeCount() int
- func (p *Program) UnresolvedPackageNames() *collections.Set[string]
- func (p *Program) UpdateProgram(changedFilePath tspath.PathKey, newHost CompilerHost, ...) (*Program, *ast.SourceFile, bool)
- func (p *Program) UseCaseSensitiveFileNames() bool
- func (p *Program) UsesUriStyleNodeCoreModules() core.Tristate
- type ProgramConfig
- type ProgramFactories
- type ProgramHosts
- type ProgramLike
- type ProgramOptions
- type SourceFileMayBeEmittedHost
- type SourceMapEmitResult
- type WriteFile
- type WriteFileData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentMapperInitializationDiagnostic ¶
func ContentMapperInitializationDiagnostic(label string, err error) *ast.Diagnostic
ContentMapperInitializationDiagnostic returns a fileless diagnostic for a mapper initialization failure.
func ContentMapperProjectDiagnostic ¶
func ContentMapperProjectDiagnostic(err error) *ast.Diagnostic
ContentMapperProjectDiagnostic returns a fileless diagnostic for project setup or mapper initialization.
func ContentMapperProjectErrorDiagnostic ¶
func ContentMapperProjectErrorDiagnostic(err error) *diagnostics.Message
ContentMapperProjectErrorDiagnostic returns the localized diagnostic message for a project setup error.
func FilterNoEmitSemanticDiagnostics ¶
func FilterNoEmitSemanticDiagnostics(diagnostics []*ast.Diagnostic, options *core.CompilerOptions) []*ast.Diagnostic
func GetDiagnosticsOfAnyProgram ¶
func GetDiagnosticsOfAnyProgram( ctx context.Context, program ProgramLike, files []*ast.SourceFile, skipNoEmitCheckForDtsDiagnostics bool, getBindDiagnostics func(context.Context, *ast.SourceFile) []*ast.Diagnostic, getSemanticDiagnostics func(context.Context, *ast.SourceFile) []*ast.Diagnostic, ) []*ast.Diagnostic
func SortAndDeduplicateDiagnostics ¶
func SortAndDeduplicateDiagnostics(diagnostics []*ast.Diagnostic) []*ast.Diagnostic
Types ¶
type CheckerPool ¶
type CheckerPool interface {
GetChecker(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func())
}
CheckerPool is implemented by the project system to provide checkers with request-scoped lifetime and reclamation. It returns a checker and a release function that must be called when the caller is done with the checker. The returned checker must not be accessed concurrently; each acquisition is exclusive. Acquisitions are not reentrant, even when they share a request ID. Callers must pass an already acquired checker to nested operations instead of acquiring again. If file is non-nil, the pool may use it as an affinity hint to return the same checker for the same file across calls.
type CompilerHost ¶
type CompilerHost interface {
FS() vfs.FS
DefaultLibraryPath() tspath.RootedDirectoryPath
Trace(msg *diagnostics.Message, args ...any)
GetSourceFile(opts ast.SourceFileParseOptions) *ast.SourceFile
// GetContentMappedSourceFile produces the source file for a content-mapped (foreign) file by running
// the given mapper's transform on the file's content. The caller resolves the mapper (and owns the
// failure accounting), so implementations must use it as-is. It returns nil if the file cannot be read,
// or an error if the transform fails or the mapper produces invalid position mappings. Implementations
// may cache successful results.
GetContentMappedSourceFiles(parseOptions ast.SourceFileParseOptions, mapper *contentmapper.Mapper) (contentmapper.SourceFiles, error)
// ContentMapperProject returns the project-scoped content mapper used by this host, or nil when the
// command line has no content mappers. The project owns transform identity and lifecycle state.
ContentMapperProject() contentmapper.Project
GetResolvedProjectReference(fileName tspath.RootedFilePath, path tspath.PathKey) *tsoptions.ParsedCommandLine
}
func NewCachedFSCompilerHost ¶
func NewCachedFSCompilerHost( fs vfs.FS, defaultLibraryPath tspath.RootedDirectoryPath, extendedConfigCache tsoptions.ExtendedConfigCache, trace func(msg *diagnostics.Message, args ...any), contentMapperProject contentmapper.Project, ) CompilerHost
func NewCompilerHost ¶
func NewCompilerHost( fs vfs.FS, defaultLibraryPath tspath.RootedDirectoryPath, extendedConfigCache tsoptions.ExtendedConfigCache, trace func(msg *diagnostics.Message, args ...any), contentMapperProject contentmapper.Project, ) CompilerHost
type DuplicateSourceFile ¶
type DuplicateSourceFile struct {
ParseOptions ast.SourceFileParseOptions
// ContentMapperParseOptions are the acquire-time options for a content-mapped parse-cache entry.
ContentMapperParseOptions ast.SourceFileParseOptions
Hash xxh3.Uint128
ScriptKind core.ScriptKind
// ContentMapper is the identity of the content mapper that produced this file,
// or "" if the file is not content-mapped.
ContentMapper string
// IsContentMapperFailureStub reports whether the file is an empty placeholder
// from a failed transform.
IsContentMapperFailureStub bool
}
type EmitHost ¶
type EmitHost interface {
printer.EmitHost
declarations.DeclarationEmitHost
Options() *core.CompilerOptions
SourceFiles() []*ast.SourceFile
CaseSensitivity() tspath.CaseSensitivity
BaseDirectory() tspath.RootedDirectoryPath
CommonSourceDirectory() tspath.RootedDirectoryPath
IsEmitBlocked(file tspath.RootedFilePath) bool
}
NOTE: EmitHost operations must be thread-safe
type EmitOptions ¶
type EmitOptions struct {
TargetSourceFiles []*ast.SourceFile // Source files to emit. If `nil`, emits all files
EmitOnly EmitOnly
ForceEmit bool
WriteFile WriteFile
}
type EmitResult ¶
type EmitResult struct {
EmitSkipped bool
Diagnostics []*ast.Diagnostic // Contains declaration emit diagnostics
EmittedFiles []tspath.RootedFilePath // Array of files the compiler wrote to disk
SourceMaps []*SourceMapEmitResult // Array of sourceMapData if compiler emitted sourcemaps
}
func CombineEmitResults ¶
func CombineEmitResults(results []*EmitResult) *EmitResult
func HandleNoEmitOptions ¶
func HandleNoEmitOptions(ctx context.Context, program ProgramLike, files []*ast.SourceFile, emitBuildInfo func() *EmitResult) *EmitResult
HandleNoEmitOptions mirrors tsc's handleNoEmitOptions.
type FileIncludeReason ¶
type FileIncludeReason struct {
// contains filtered or unexported fields
}
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
func NewProgram ¶
func NewProgram(opts ProgramOptions) *Program
func (*Program) BaseDirectory ¶
func (p *Program) BaseDirectory() tspath.RootedDirectoryPath
BaseDirectory implements checker.Program.
func (*Program) BindSourceFiles ¶
func (p *Program) BindSourceFiles()
func (*Program) CaseSensitivity ¶
func (p *Program) CaseSensitivity() tspath.CaseSensitivity
func (*Program) CommandLine ¶
func (p *Program) CommandLine() *tsoptions.ParsedCommandLine
func (*Program) CommonSourceDirectory ¶
func (p *Program) CommonSourceDirectory() tspath.RootedDirectoryPath
func (*Program) ContentMapperExtensions ¶
func (*Program) ContentMapperProject ¶
func (p *Program) ContentMapperProject() contentmapper.Project
func (*Program) DeepImportPackageNames ¶
func (p *Program) DeepImportPackageNames() *collections.Set[string]
func (*Program) DuplicateSourceFiles ¶
func (p *Program) DuplicateSourceFiles() []*DuplicateSourceFile
func (*Program) Emit ¶
func (p *Program) Emit(ctx context.Context, options EmitOptions) *EmitResult
func (*Program) ExplainFiles ¶
func (*Program) FileExists ¶
func (p *Program) FileExists(path tspath.RootedFilePath) bool
FileExists implements checker.Program.
func (*Program) FilesByPath ¶
func (p *Program) FilesByPath() map[tspath.PathKey]*ast.SourceFile
func (*Program) ForEachCheckerParallel ¶
func (*Program) ForEachResolvedModule ¶
func (p *Program) ForEachResolvedModule(callback func(resolution *module.ResolvedModule, moduleName string, mode core.ResolutionMode, filePath tspath.PathKey), file *ast.SourceFile)
func (*Program) ForEachResolvedTypeReferenceDirective ¶
func (p *Program) ForEachResolvedTypeReferenceDirective(callback func(resolution *module.ResolvedTypeReferenceDirective, moduleName string, mode core.ResolutionMode, filePath tspath.PathKey), file *ast.SourceFile)
func (*Program) GetBindDiagnostics ¶
func (p *Program) GetBindDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic
func (*Program) GetCheckerPool ¶
func (p *Program) GetCheckerPool() CheckerPool
GetCheckerPool returns the checker pool associated with this program.
func (*Program) GetConfigFileParsingDiagnostics ¶
func (p *Program) GetConfigFileParsingDiagnostics() []*ast.Diagnostic
func (*Program) GetContentMapper ¶
func (p *Program) GetContentMapper(file *ast.SourceFile) *contentmapper.Mapper
GetContentMapper returns the content mapper that produced the given source file, or nil if the file was not produced by a content mapper.
func (*Program) GetCurrentDirectory ¶
func (p *Program) GetCurrentDirectory() tspath.RootedDirectoryPath
func (*Program) GetDeclarationDiagnostics ¶
func (p *Program) GetDeclarationDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic
func (*Program) GetDefaultLibFile ¶
func (*Program) GetDefaultResolutionModeForFile ¶
func (p *Program) GetDefaultResolutionModeForFile(sourceFile ast.HasFileName) core.ResolutionMode
func (*Program) GetEmitModuleFormatOfFile ¶
func (p *Program) GetEmitModuleFormatOfFile(sourceFile ast.HasFileName) core.ModuleKind
func (*Program) GetEmitSyntaxForUsageLocation ¶
func (p *Program) GetEmitSyntaxForUsageLocation(sourceFile ast.HasFileName, location *ast.StringLiteralLike) core.ResolutionMode
func (*Program) GetGlobalDiagnostics ¶
func (p *Program) GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic
func (*Program) GetGlobalTypingsCacheLocation ¶
func (p *Program) GetGlobalTypingsCacheLocation() tspath.RootedDirectoryPath
GetGlobalTypingsCacheLocation implements checker.Program.
func (*Program) GetImpliedNodeFormatForEmit ¶
func (p *Program) GetImpliedNodeFormatForEmit(sourceFile ast.HasFileName) core.ResolutionMode
func (*Program) GetImportHelpersImportSpecifier ¶
func (*Program) GetIncludeProcessorDiagnostics ¶
func (p *Program) GetIncludeProcessorDiagnostics(sourceFile *ast.SourceFile) []*ast.Diagnostic
func (*Program) GetIncludeReasons ¶
func (p *Program) GetIncludeReasons() map[tspath.PathKey][]*FileIncludeReason
Testing only
func (*Program) GetJSXRuntimeImportSpecifier ¶
func (*Program) GetLibFileFromReference ¶
func (p *Program) GetLibFileFromReference(ref *ast.FileReference) *ast.SourceFile
func (*Program) GetModeForResolutionAtIndex ¶
func (p *Program) GetModeForResolutionAtIndex(sourceFile *ast.SourceFile, index int) core.ResolutionMode
func (*Program) GetModeForUsageLocation ¶
func (p *Program) GetModeForUsageLocation(sourceFile ast.HasFileName, location *ast.StringLiteralLike) core.ResolutionMode
func (*Program) GetNearestAncestorDirectoryWithPackageJson ¶
func (p *Program) GetNearestAncestorDirectoryWithPackageJson(dirname tspath.RootedDirectoryPath) tspath.RootedDirectoryPath
GetNearestAncestorDirectoryWithPackageJson implements checker.Program.
func (*Program) GetPackageJsonInfo ¶
func (p *Program) GetPackageJsonInfo(pkgJsonPath tspath.RootedFilePath) *packagejson.InfoCacheEntry
GetPackageJsonInfo implements checker.Program.
func (*Program) GetPackagesMap ¶
GetPackagesMap returns a lazily-cached map of package names to whether they bundle types. This is used by incremental diagnostic repopulation.
func (*Program) GetParseFileRedirect ¶
func (p *Program) GetParseFileRedirect(fileName tspath.RootedFilePath) tspath.RootedFilePath
func (*Program) GetProgramDiagnostics ¶
func (p *Program) GetProgramDiagnostics() []*ast.Diagnostic
func (*Program) GetProjectReferenceFromOutputDts ¶
func (p *Program) GetProjectReferenceFromOutputDts(path tspath.PathKey) *tsoptions.SourceOutputAndProjectReference
func (*Program) GetProjectReferenceFromSource ¶
func (p *Program) GetProjectReferenceFromSource(path tspath.PathKey) *tsoptions.SourceOutputAndProjectReference
GetProjectReferenceFromSource implements checker.Program.
func (*Program) GetRedirectForResolution ¶
func (p *Program) GetRedirectForResolution(file ast.HasFileName) *tsoptions.ParsedCommandLine
func (*Program) GetRedirectTargets ¶
func (p *Program) GetRedirectTargets(path tspath.PathKey) []tspath.RootedFilePath
GetRedirectTargets returns the list of file paths that redirect to the given path. These are files from the same package (same name@version) installed in different locations.
func (*Program) GetResolvedModule ¶
func (p *Program) GetResolvedModule(file ast.HasFileName, moduleReference string, mode core.ResolutionMode) *module.ResolvedModule
func (*Program) GetResolvedModuleFromModuleSpecifier ¶
func (p *Program) GetResolvedModuleFromModuleSpecifier(file ast.HasFileName, moduleSpecifier *ast.StringLiteralLike) *module.ResolvedModule
func (*Program) GetResolvedModules ¶
func (p *Program) GetResolvedModules() map[tspath.PathKey]module.ModeAwareCache[*module.ResolvedModule]
func (*Program) GetResolvedProjectReferenceFor ¶
func (*Program) GetResolvedProjectReferences ¶
func (p *Program) GetResolvedProjectReferences() []*tsoptions.ParsedCommandLine
func (*Program) GetResolvedTypeReferenceDirective ¶
func (p *Program) GetResolvedTypeReferenceDirective(file ast.HasFileName, typeDirectiveName string, mode core.ResolutionMode) *module.ResolvedTypeReferenceDirective
func (*Program) GetResolvedTypeReferenceDirectiveFromTypeReferenceDirective ¶
func (p *Program) GetResolvedTypeReferenceDirectiveFromTypeReferenceDirective(typeRef *ast.FileReference, sourceFile *ast.SourceFile) *module.ResolvedTypeReferenceDirective
func (*Program) GetResolvedTypeReferenceDirectives ¶
func (p *Program) GetResolvedTypeReferenceDirectives() map[tspath.PathKey]module.ModeAwareCache[*module.ResolvedTypeReferenceDirective]
func (*Program) GetSemanticDiagnostics ¶
func (p *Program) GetSemanticDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic
func (*Program) GetSemanticDiagnosticsForIncremental ¶
func (p *Program) GetSemanticDiagnosticsForIncremental(ctx context.Context, sourceFiles []*ast.SourceFile) map[*ast.SourceFile][]*ast.Diagnostic
GetSemanticDiagnosticsForIncremental includes newly discovered globals in each file's cached diagnostics and leaves noEmit filtering to the builder.
func (*Program) GetSourceFile ¶
func (p *Program) GetSourceFile(fileName tspath.RootedFilePath) *ast.SourceFile
func (*Program) GetSourceFileByPath ¶
func (p *Program) GetSourceFileByPath(path tspath.PathKey) *ast.SourceFile
func (*Program) GetSourceFileForResolvedModule ¶
func (p *Program) GetSourceFileForResolvedModule(resolved *module.ResolvedModule) *ast.SourceFile
func (*Program) GetSourceFileFromReference ¶
func (p *Program) GetSourceFileFromReference(origin *ast.SourceFile, ref *ast.FileReference) *ast.SourceFile
* This should have similar behavior to 'processSourceFile' without diagnostics or mutation.
func (*Program) GetSourceFileMetaData ¶
func (p *Program) GetSourceFileMetaData(path tspath.PathKey) ast.SourceFileMetaData
func (*Program) GetSourceFiles ¶
func (p *Program) GetSourceFiles() []*ast.SourceFile
func (*Program) GetSourceOfProjectReferenceIfOutputIncluded ¶
func (p *Program) GetSourceOfProjectReferenceIfOutputIncluded(file ast.HasFileName) tspath.RootedFilePath
gets the original file that was included in program this returns original source file name when including output of project reference otherwise same name Equivalent to originalFileName on SourceFile in Strada
func (*Program) GetSuggestionDiagnostics ¶
func (p *Program) GetSuggestionDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic
func (*Program) GetSymlinkCache ¶
func (p *Program) GetSymlinkCache() *symlinks.KnownSymlinks
func (*Program) GetSyntacticDiagnostics ¶
func (p *Program) GetSyntacticDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic
func (*Program) GetTypeChecker ¶
Return the type checker associated with the program.
func (*Program) GetTypeCheckerForFile ¶
func (p *Program) GetTypeCheckerForFile(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func())
Return a checker for the given file. We may have multiple checkers in concurrent scenarios and this method returns the checker that was tasked with checking the file. Note that it isn't possible to mix types obtained from different checkers, so only non-type data (such as diagnostics or string representations of types) should be obtained from checkers returned by this method.
func (*Program) GetTypeCheckerForFileExclusive ¶
func (p *Program) GetTypeCheckerForFileExclusive(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func())
Return a checker for the given file, locked to the current thread to prevent data races from multiple threads accessing the same checker. The lock will be released when the `done` function is called.
func (*Program) GetUnresolvedImports ¶
func (p *Program) GetUnresolvedImports() *collections.Set[string]
GetUnresolvedImports returns the unresolved imports for this program. The result is cached and computed only once.
func (*Program) HasSameFileNames ¶
func (*Program) Host ¶
func (p *Program) Host() CompilerHost
func (*Program) IdentifierCount ¶
func (*Program) InstantiationCount ¶
func (*Program) IsEmitBlocked ¶
func (p *Program) IsEmitBlocked(emitFileName tspath.RootedFilePath) bool
func (*Program) IsGlobalTypingsFile ¶
func (p *Program) IsGlobalTypingsFile(fileName tspath.RootedFilePath) bool
func (*Program) IsMissingPath ¶
Testing only
func (*Program) IsSourceFileDefaultLibrary ¶
func (*Program) IsSourceFileFromExternalLibrary ¶
func (p *Program) IsSourceFileFromExternalLibrary(file *ast.SourceFile) bool
func (*Program) IsSourceFromProjectReference ¶
IsSourceFromProjectReference implements checker.Program.
func (*Program) ModuleResolutionError ¶
func (*Program) Options ¶
func (p *Program) Options() *core.CompilerOptions
func (*Program) PackageJsonCacheEntries ¶
func (p *Program) PackageJsonCacheEntries(f func(key tspath.PathKey, value *packagejson.InfoCacheEntry) bool)
PackageJsonCacheEntries iterates on all package json cache entries.
func (*Program) PathKeyForFileName ¶
func (p *Program) PathKeyForFileName(fileName tspath.RootedFilePath) tspath.PathKey
func (*Program) RangeResolvedProjectReference ¶
func (p *Program) RangeResolvedProjectReference(f func(path tspath.PathKey, config *tsoptions.ParsedCommandLine, parent *tsoptions.ParsedCommandLine, index int) bool) bool
func (*Program) RangeResolvedProjectReferenceInChildConfig ¶
func (p *Program) RangeResolvedProjectReferenceInChildConfig( childConfig *tsoptions.ParsedCommandLine, f func(path tspath.PathKey, config *tsoptions.ParsedCommandLine, parent *tsoptions.ParsedCommandLine, index int) bool, ) bool
func (*Program) ResolvedPackageNames ¶
func (p *Program) ResolvedPackageNames() *collections.Set[string]
func (*Program) ReuseProgram ¶
func (p *Program) ReuseProgram( changedFilePath tspath.PathKey, newHost CompilerHost, createCheckerPool func(*Program) CheckerPool, createModuleResolver func(module.ResolverOptions) module.Resolver, ) (*Program, *ast.SourceFile, bool)
ReuseProgram attempts to produce a new program by replacing only changedFilePath in place, reusing the rest of p. It returns (newProgram, newFile, true) on success, or (nil, newFile, false) when the file cannot be replaced in place. Unlike UpdateProgram, it never constructs a full fallback program, so callers that build their own fallback (e.g. with a different host) do not pay for a discarded program build.
func (*Program) SingleThreaded ¶
func (*Program) SkipTypeChecking ¶
func (p *Program) SkipTypeChecking(sourceFile *ast.SourceFile, ignoreNoCheck bool) bool
func (*Program) SourceFileMayBeEmitted ¶
func (p *Program) SourceFileMayBeEmitted(sourceFile *ast.SourceFile, forceDtsEmit bool) bool
func (*Program) SourceFiles ¶
func (p *Program) SourceFiles() []*ast.SourceFile
func (*Program) SymbolCount ¶
func (*Program) UnresolvedPackageNames ¶
func (p *Program) UnresolvedPackageNames() *collections.Set[string]
func (*Program) UpdateProgram ¶
func (p *Program) UpdateProgram( changedFilePath tspath.PathKey, newHost CompilerHost, createCheckerPool func(*Program) CheckerPool, createModuleResolver func(module.ResolverOptions) module.Resolver, ) (*Program, *ast.SourceFile, bool)
Return an updated program for which it is known that only the file with the given path has changed. In addition to a new program, return a boolean indicating whether the data of the old program was reused. The returned *ast.SourceFile is the changed file as acquired through newHost; it is nil only if the host cannot locate the file (e.g. it was deleted). Callers that manage host-side parse caches must release this exact pointer when the old program could not be reused, since it was acquired speculatively before that decision was made.
func (*Program) UseCaseSensitiveFileNames ¶
func (*Program) UsesUriStyleNodeCoreModules ¶
type ProgramConfig ¶
type ProgramConfig struct {
Config *tsoptions.ParsedCommandLine
UseSourceOfProjectReference bool
SingleThreaded core.Tristate
TypingsLocation tspath.RootedDirectoryPath
ProjectName string
// SkipModuleResolution avoids all module and type reference resolution while
// still collecting import metadata needed for emit.
SkipModuleResolution bool
}
type ProgramFactories ¶
type ProgramFactories struct {
CreateCheckerPool func(*Program) CheckerPool
CreateModuleResolver func(module.ResolverOptions) module.Resolver
}
type ProgramHosts ¶
type ProgramHosts struct {
Host CompilerHost
Tracing *tracing.Tracing
}
type ProgramLike ¶
type ProgramLike interface {
Options() *core.CompilerOptions
GetSourceFile(fileName tspath.RootedFilePath) *ast.SourceFile
GetSourceFiles() []*ast.SourceFile
GetConfigFileParsingDiagnostics() []*ast.Diagnostic
GetSyntacticDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic
GetBindDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic
GetProgramDiagnostics() []*ast.Diagnostic
GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic
GetSemanticDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic
GetDeclarationDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic
GetSuggestionDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic
Emit(ctx context.Context, options EmitOptions) *EmitResult
CommonSourceDirectory() tspath.RootedDirectoryPath
IsSourceFileDefaultLibrary(path tspath.PathKey) bool
Program() *Program
}
type ProgramOptions ¶
type ProgramOptions struct {
ProgramConfig
ProgramHosts
ProgramFactories
}
type SourceFileMayBeEmittedHost ¶
type SourceFileMayBeEmittedHost interface {
Options() *core.CompilerOptions
GetProjectReferenceFromSource(path tspath.PathKey) *tsoptions.SourceOutputAndProjectReference
IsSourceFileFromExternalLibrary(file *ast.SourceFile) bool
BaseDirectory() tspath.RootedDirectoryPath
CaseSensitivity() tspath.CaseSensitivity
SourceFiles() []*ast.SourceFile
}
type SourceMapEmitResult ¶
type SourceMapEmitResult struct {
InputSourceFileNames []string // Input source file (which one can use on program to get the file), 1:1 mapping with the sourceMap.sources list
SourceMap *sourcemap.RawSourceMap
GeneratedFile string
}
type WriteFile ¶
type WriteFile func(fileName tspath.RootedFilePath, text string, data *WriteFileData) error
type WriteFileData ¶
type WriteFileData struct {
SourceMapUrlPos int
BuildInfo any
Diagnostics []*ast.Diagnostic
SkippedDtsWrite bool
SourceFile *ast.SourceFile
}