MCPcopy Create free account
hub / github.com/microsoft/typescript-go / getPreferredEnding

Function getPreferredEnding

internal/modulespecifiers/preferences.go:114–139  ·  view source on GitHub ↗
(
	prefs UserPreferences,
	host ModuleSpecifierGenerationHost,
	compilerOptions *core.CompilerOptions,
	importingSourceFile SourceFileForSpecifierGeneration,
	oldImportSpecifier string,
	resolutionMode core.ResolutionMode,
)

Source from the content-addressed store, hash-verified

112}
113
114func getPreferredEnding(
115 prefs UserPreferences,
116 host ModuleSpecifierGenerationHost,
117 compilerOptions *core.CompilerOptions,
118 importingSourceFile SourceFileForSpecifierGeneration,
119 oldImportSpecifier string,
120 resolutionMode core.ResolutionMode,
121) ModuleSpecifierEnding {
122 if len(oldImportSpecifier) > 0 {
123 if tspath.HasJSFileExtension(oldImportSpecifier) {
124 return ModuleSpecifierEndingJsExtension
125 }
126 if strings.HasSuffix(oldImportSpecifier, "/index") {
127 return ModuleSpecifierEndingIndex
128 }
129 }
130 if resolutionMode == core.ResolutionModeNone {
131 resolutionMode = host.GetDefaultResolutionModeForFile(importingSourceFile)
132 }
133 return getModuleSpecifierEndingPreference(
134 prefs.ImportModuleSpecifierEnding,
135 resolutionMode,
136 compilerOptions,
137 importingSourceFile,
138 )
139}
140
141type ModuleSpecifierPreferences struct {
142 relativePreference RelativePreferenceKind

Callers 1

Calls 4

HasJSFileExtensionFunction · 0.92
lenFunction · 0.85

Tested by

no test coverage detected