forked from microsoft/typescript-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
124 lines (101 loc) · 3.95 KB
/
types.go
File metadata and controls
124 lines (101 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package modulespecifiers
import (
"github.com/microsoft/typescript-go/internal/ast"
"github.com/microsoft/typescript-go/internal/core"
"github.com/microsoft/typescript-go/internal/module"
"github.com/microsoft/typescript-go/internal/packagejson"
"github.com/microsoft/typescript-go/internal/tsoptions"
"github.com/microsoft/typescript-go/internal/tspath"
)
type SourceFileForSpecifierGeneration interface {
Path() tspath.Path
FileName() string
Imports() []*ast.StringLiteralLike
IsJS() bool
}
type CheckerShape interface {
GetSymbolAtLocation(node *ast.Node) *ast.Symbol
GetAliasedSymbol(symbol *ast.Symbol) *ast.Symbol
}
type ResultKind uint8
const (
ResultKindNone ResultKind = iota
ResultKindNodeModules
ResultKindPaths
ResultKindRedirect
ResultKindRelative
ResultKindAmbient
)
type ModulePath struct {
FileName string
IsInNodeModules bool
IsRedirect bool
}
type PackageJsonInfo interface {
GetDirectory() string
GetContents() *packagejson.PackageJson
}
type ModuleSpecifierGenerationHost interface {
// GetModuleResolutionCache() any // !!! TODO: adapt new resolution cache model
// GetSymlinkCache() any // !!! TODO: adapt new resolution cache model
// GetFileIncludeReasons() any // !!! TODO: adapt new resolution cache model
CommonSourceDirectory() string
GetGlobalTypingsCacheLocation() string
UseCaseSensitiveFileNames() bool
GetCurrentDirectory() string
GetProjectReferenceFromSource(path tspath.Path) *tsoptions.SourceOutputAndProjectReference
GetRedirectTargets(path tspath.Path) []string
GetSourceOfProjectReferenceIfOutputIncluded(file ast.HasFileName) string
FileExists(path string) bool
GetNearestAncestorDirectoryWithPackageJson(dirname string) string
GetPackageJsonInfo(pkgJsonPath string) PackageJsonInfo
GetDefaultResolutionModeForFile(file ast.HasFileName) core.ResolutionMode
GetResolvedModuleFromModuleSpecifier(file ast.HasFileName, moduleSpecifier *ast.StringLiteralLike) *module.ResolvedModule
GetModeForUsageLocation(file ast.HasFileName, moduleSpecifier *ast.StringLiteralLike) core.ResolutionMode
IsNodeSourceFile(path tspath.Path) bool
GetDenoForkContextInfo() ast.DenoForkContextInfo
}
type ImportModuleSpecifierPreference string
const (
ImportModuleSpecifierPreferenceNone ImportModuleSpecifierPreference = ""
ImportModuleSpecifierPreferenceShortest ImportModuleSpecifierPreference = "shortest"
ImportModuleSpecifierPreferenceProjectRelative ImportModuleSpecifierPreference = "project-relative"
ImportModuleSpecifierPreferenceRelative ImportModuleSpecifierPreference = "relative"
ImportModuleSpecifierPreferenceNonRelative ImportModuleSpecifierPreference = "non-relative"
)
type ImportModuleSpecifierEndingPreference string
const (
ImportModuleSpecifierEndingPreferenceNone ImportModuleSpecifierEndingPreference = ""
ImportModuleSpecifierEndingPreferenceAuto ImportModuleSpecifierEndingPreference = "auto"
ImportModuleSpecifierEndingPreferenceMinimal ImportModuleSpecifierEndingPreference = "minimal"
ImportModuleSpecifierEndingPreferenceIndex ImportModuleSpecifierEndingPreference = "index"
ImportModuleSpecifierEndingPreferenceJs ImportModuleSpecifierEndingPreference = "js"
)
type UserPreferences struct {
ImportModuleSpecifierPreference ImportModuleSpecifierPreference
ImportModuleSpecifierEnding ImportModuleSpecifierEndingPreference
AutoImportSpecifierExcludeRegexes []string
}
type ModuleSpecifierOptions struct {
OverrideImportMode core.ResolutionMode
}
type RelativePreferenceKind uint8
const (
RelativePreferenceRelative RelativePreferenceKind = iota
RelativePreferenceNonRelative
RelativePreferenceShortest
RelativePreferenceExternalNonRelative
)
type ModuleSpecifierEnding uint8
const (
ModuleSpecifierEndingMinimal ModuleSpecifierEnding = iota
ModuleSpecifierEndingIndex
ModuleSpecifierEndingJsExtension
ModuleSpecifierEndingTsExtension
)
type MatchingMode uint8
const (
MatchingModeExact MatchingMode = iota
MatchingModeDirectory
MatchingModePattern
)