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

Function validateEnding

internal/modulespecifiers/specifiers.go:1188–1197  ·  view source on GitHub ↗
(c specPair, relativeToBaseUrl string, compilerOptions *core.CompilerOptions, host ModuleSpecifierGenerationHost)

Source from the content-addressed store, hash-verified

1186}
1187
1188func validateEnding(c specPair, relativeToBaseUrl string, compilerOptions *core.CompilerOptions, host ModuleSpecifierGenerationHost) bool {
1189 // Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename
1190 // is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only
1191 // here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls),
1192 // do we check that the host-validated result is consistent with the answer we got before. If it's not, it falls back to the
1193 // `ModuleSpecifierEnding.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is
1194 // that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally
1195 // everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.)
1196 return c.ending != ModuleSpecifierEndingMinimal || c.value == processEnding(relativeToBaseUrl, []ModuleSpecifierEnding{c.ending}, compilerOptions, host)
1197}
1198
1199func tryGetModuleNameFromExportsOrImports(
1200 options *core.CompilerOptions,

Callers 1

Calls 1

processEndingFunction · 0.85

Tested by

no test coverage detected