Documentation
¶
Index ¶
- Constants
- func ComparePatternKeys(a, b string) int
- func GetAutomaticTypeDirectiveNames(options *core.CompilerOptions, host ResolutionHost) []string
- func GetCompilerOptionsWithRedirect(compilerOptions *core.CompilerOptions, ...) *core.CompilerOptions
- func GetConditions(options *core.CompilerOptions, resolutionMode core.ResolutionMode) []string
- func GetPackageNameFromTypesPackageName(mangledName string) string
- func GetResolutionDiagnostic(options *core.CompilerOptions, resolvedModule *ResolvedModule, ...) *diagnostics.Message
- func GetTypesPackageName(packageName string) string
- func IsApplicableVersionedTypesKey(key string) bool
- func MangleScopedPackageName(packageName string) string
- func MatchPatternOrExact(patterns *ParsedPatterns, candidate string) core.Pattern
- func ParseNodeModuleFromPath(resolved string, isFolder bool) string
- func ParsePackageName(moduleName string) (packageName, rest string)
- func TryGetJSExtensionForFile(fileName string, options *core.CompilerOptions) string
- func UnmangleScopedPackageName(packageName string) string
- type DiagAndArgs
- type Ending
- type LookupLocations
- type ModeAwareCache
- type ModeAwareCacheKey
- type NodeResolutionFeatures
- type PackageId
- type ParsedPatterns
- type ResolutionHost
- type ResolvedEntrypoint
- type ResolvedEntrypoints
- type ResolvedModule
- type ResolvedProjectReference
- type ResolvedTypeReferenceDirective
- type Resolver
- func (r *Resolver) GetEntrypointsFromPackageJsonInfo(packageJson *packagejson.InfoCacheEntry, packageName string) *ResolvedEntrypoints
- func (r *Resolver) GetPackageScopeForPath(directory string) *packagejson.InfoCacheEntry
- func (r *Resolver) ResolveModuleName(moduleName string, containingFile string, resolutionMode core.ResolutionMode, ...) (*ResolvedModule, []DiagAndArgs)
- func (r *Resolver) ResolvePackageDirectory(moduleName string, containingFile string, resolutionMode core.ResolutionMode, ...) *ResolvedModule
- func (r *Resolver) ResolveTypeReferenceDirective(typeReferenceDirectiveName string, containingFile string, ...) (*ResolvedTypeReferenceDirective, []DiagAndArgs)
Constants ¶
View Source
const ( NodeResolutionFeaturesImports NodeResolutionFeatures = 1 << iota NodeResolutionFeaturesSelfName NodeResolutionFeaturesExports NodeResolutionFeaturesExportsPatternTrailers // allowing `#/` root imports in package.json imports field // not supported until mass adoption - https://github.com/nodejs/node/pull/60864 NodeResolutionFeaturesImportsPatternRoot NodeResolutionFeaturesNone NodeResolutionFeatures = 0 NodeResolutionFeaturesAll = NodeResolutionFeaturesImports | NodeResolutionFeaturesSelfName | NodeResolutionFeaturesExports | NodeResolutionFeaturesExportsPatternTrailers | NodeResolutionFeaturesImportsPatternRoot NodeResolutionFeaturesNode16Default = NodeResolutionFeaturesImports | NodeResolutionFeaturesSelfName | NodeResolutionFeaturesExports | NodeResolutionFeaturesExportsPatternTrailers NodeResolutionFeaturesNodeNextDefault = NodeResolutionFeaturesAll NodeResolutionFeaturesBundlerDefault = NodeResolutionFeaturesImports | NodeResolutionFeaturesSelfName | NodeResolutionFeaturesExports | NodeResolutionFeaturesExportsPatternTrailers | NodeResolutionFeaturesImportsPatternRoot )
View Source
const InferredTypesContainingFile = "__inferred type names__.ts"
Variables ¶
This section is empty.
Functions ¶
func ComparePatternKeys ¶
func GetAutomaticTypeDirectiveNames ¶
func GetAutomaticTypeDirectiveNames(options *core.CompilerOptions, host ResolutionHost) []string
func GetCompilerOptionsWithRedirect ¶
func GetCompilerOptionsWithRedirect(compilerOptions *core.CompilerOptions, redirectedReference ResolvedProjectReference) *core.CompilerOptions
func GetConditions ¶
func GetConditions(options *core.CompilerOptions, resolutionMode core.ResolutionMode) []string
func GetResolutionDiagnostic ¶
func GetResolutionDiagnostic(options *core.CompilerOptions, resolvedModule *ResolvedModule, file *ast.SourceFile) *diagnostics.Message
Returns a DiagnosticMessage if we won't include a resolved module due to its extension. The DiagnosticMessage's parameters are the imported module name, and the filename it resolved to. This returns a diagnostic even if the module will be an untyped module.
func GetTypesPackageName ¶
func MangleScopedPackageName ¶
func MatchPatternOrExact ¶
func MatchPatternOrExact(patterns *ParsedPatterns, candidate string) core.Pattern
func ParseNodeModuleFromPath ¶
func ParsePackageName ¶
func TryGetJSExtensionForFile ¶
func TryGetJSExtensionForFile(fileName string, options *core.CompilerOptions) string
TryGetJSExtensionForFile maps TS/JS/DTS extensions to the output JS-side extension. Returns an empty string if the extension is unsupported.
Types ¶
type DiagAndArgs ¶
type DiagAndArgs struct {
Message *diagnostics.Message
Args []any
}
type Ending ¶
type Ending int
const ( // EndingFixed indicates that the module specifier cannot be changed without changing its resolution. EndingFixed Ending = iota // EndingExtensionChangeable indicates that the module specifier's extension portion was inferred from a // file on disk, so an interchangeable one could be used instead (e.g. replacing .d.ts with .js). EndingExtensionChangeable // EndingChangeable indicates that the module specifier's file name and extension portion were inferred // from a file on disk without being matched as part of an 'exports' pattern, so can be changed according // to the importer's module resolution rules (e.g. an /index.d.ts may be dropped entirely in CommonJS settings). EndingChangeable )
type LookupLocations ¶
type LookupLocations struct {
FailedLookupLocations []string
AffectingLocations []string
ResolutionDiagnostics []*ast.Diagnostic
}
type ModeAwareCache ¶
type ModeAwareCache[T any] map[ModeAwareCacheKey]T
type ModeAwareCacheKey ¶
type ModeAwareCacheKey struct {
Name string
Mode core.ResolutionMode
}
type NodeResolutionFeatures ¶
type NodeResolutionFeatures int32
type PackageId ¶
func (*PackageId) PackageName ¶
type ParsedPatterns ¶
type ParsedPatterns struct {
// contains filtered or unexported fields
}
func TryParsePatterns ¶
func TryParsePatterns(pathMappings *collections.OrderedMap[string, []string]) *ParsedPatterns
type ResolutionHost ¶
type ResolvedEntrypoint ¶
type ResolvedEntrypoint struct {
// OriginalFileName is the symlink path if the entrypoint was discovered at a symlink. Empty otherwise.
OriginalFileName string
// ResolvedFileName is the real path to the entrypoint file.
ResolvedFileName string
ModuleSpecifier string
// Ending indicates whether the file name and extension portion of ModuleSpecifier is fixed or can be changed.
Ending Ending
// IncludeConditions are the conditions that a resolver must have to reach this entrypoint.
IncludeConditions *collections.Set[string]
// ExcludeConditions are the conditions that a resolver must not have to reach this entrypoint.
ExcludeConditions *collections.Set[string]
}
func (*ResolvedEntrypoint) SymlinkOrRealpath ¶
func (e *ResolvedEntrypoint) SymlinkOrRealpath() string
type ResolvedEntrypoints ¶
type ResolvedEntrypoints struct {
Entrypoints []*ResolvedEntrypoint
FailedLookupLocations []string
}
type ResolvedModule ¶
type ResolvedModule struct {
LookupLocations
ResolvedFileName string
OriginalPath string
Extension string
ResolvedUsingTsExtension bool
PackageId PackageId
IsExternalLibraryImport bool
AlternateResult string
}
func ResolveConfig ¶
func ResolveConfig(moduleName string, containingFile string, host ResolutionHost) *ResolvedModule
func (*ResolvedModule) GetLookupLocations ¶
func (r *ResolvedModule) GetLookupLocations() *LookupLocations
func (*ResolvedModule) IsResolved ¶
func (r *ResolvedModule) IsResolved() bool
type ResolvedProjectReference ¶
type ResolvedProjectReference interface {
ConfigName() string
CompilerOptions() *core.CompilerOptions
}
type ResolvedTypeReferenceDirective ¶
type ResolvedTypeReferenceDirective struct {
LookupLocations
Primary bool
ResolvedFileName string
OriginalPath string
PackageId PackageId
IsExternalLibraryImport bool
}
func (*ResolvedTypeReferenceDirective) GetLookupLocations ¶
func (r *ResolvedTypeReferenceDirective) GetLookupLocations() *LookupLocations
func (*ResolvedTypeReferenceDirective) IsResolved ¶
func (r *ResolvedTypeReferenceDirective) IsResolved() bool
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
func NewResolver ¶
func NewResolver( host ResolutionHost, options *core.CompilerOptions, typingsLocation string, projectName string, ) *Resolver
func (*Resolver) GetEntrypointsFromPackageJsonInfo ¶
func (r *Resolver) GetEntrypointsFromPackageJsonInfo(packageJson *packagejson.InfoCacheEntry, packageName string) *ResolvedEntrypoints
func (*Resolver) GetPackageScopeForPath ¶
func (r *Resolver) GetPackageScopeForPath(directory string) *packagejson.InfoCacheEntry
func (*Resolver) ResolveModuleName ¶
func (r *Resolver) ResolveModuleName(moduleName string, containingFile string, resolutionMode core.ResolutionMode, redirectedReference ResolvedProjectReference) (*ResolvedModule, []DiagAndArgs)
func (*Resolver) ResolvePackageDirectory ¶
func (r *Resolver) ResolvePackageDirectory(moduleName string, containingFile string, resolutionMode core.ResolutionMode, redirectedReference ResolvedProjectReference) *ResolvedModule
func (*Resolver) ResolveTypeReferenceDirective ¶
func (r *Resolver) ResolveTypeReferenceDirective( typeReferenceDirectiveName string, containingFile string, resolutionMode core.ResolutionMode, redirectedReference ResolvedProjectReference, ) (*ResolvedTypeReferenceDirective, []DiagAndArgs)
Click to show internal directories.
Click to hide internal directories.