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

Function getLibraryNameFromLibFileName

internal/compiler/fileloader.go:677–698  ·  view source on GitHub ↗
(libFileName string)

Source from the content-addressed store, hash-verified

675}
676
677func getLibraryNameFromLibFileName(libFileName string) string {
678 // Support resolving to lib.dom.d.ts -> @typescript/lib-dom, and
679 // lib.dom.iterable.d.ts -> @typescript/lib-dom/iterable
680 // lib.es2015.symbol.wellknown.d.ts -> @typescript/lib-es2015/symbol-wellknown
681 components := strings.Split(libFileName, ".")
682 var path strings.Builder
683 path.WriteString("@typescript/lib-")
684 if len(components) > 1 {
685 path.WriteString(components[1])
686 }
687 i := 2
688 for i < len(components) && components[i] != "" && components[i] != "d" {
689 if i == 2 {
690 path.WriteByte('/')
691 } else {
692 path.WriteByte('-')
693 }
694 path.WriteString(components[i])
695 i++
696 }
697 return path.String()
698}
699
700func getInferredLibraryNameResolveFrom(options *core.CompilerOptions, currentDirectory string, libFileName string) string {
701 var containingDirectory string

Callers 1

pathForLibFileMethod · 0.85

Calls 2

lenFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected