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

Method handleParseConfigFile

internal/api/session.go:1013–1042  ·  view source on GitHub ↗

handleParseConfigFile parses a tsconfig.json file and returns its contents.

(ctx context.Context, params *ParseConfigFileParams)

Source from the content-addressed store, hash-verified

1011
1012// handleParseConfigFile parses a tsconfig.json file and returns its contents.
1013func (s *Session) handleParseConfigFile(ctx context.Context, params *ParseConfigFileParams) (*ConfigFileResponse, error) {
1014 configFileName := params.File.ToAbsoluteFileName(s.projectSession.GetCurrentDirectory())
1015 configFileContent, ok := s.projectSession.FS().ReadFile(configFileName)
1016 if !ok {
1017 return nil, fmt.Errorf("%w: could not read file %q", ErrClientError, configFileName)
1018 }
1019
1020 configDir := tspath.GetDirectoryPath(configFileName)
1021 tsConfigSourceFile := tsoptions.NewTsconfigSourceFileFromFilePath(
1022 configFileName,
1023 s.toPath(configFileName),
1024 configFileContent,
1025 )
1026 parsedCommandLine := tsoptions.ParseJsonSourceFileConfigFileContent(
1027 tsConfigSourceFile,
1028 s.projectSession,
1029 configDir,
1030 nil, /*existingOptions*/
1031 nil, /*existingOptionsRaw*/
1032 configFileName,
1033 nil, /*resolutionStack*/
1034 nil, /*extraFileExtensions*/
1035 nil, /*extendedConfigCache*/
1036 )
1037
1038 return &ConfigFileResponse{
1039 FileNames: parsedCommandLine.FileNames(),
1040 Options: parsedCommandLine.CompilerOptions(),
1041 }, nil
1042}
1043
1044// handleGetSourceFile returns a source file from a project within a snapshot.
1045func (s *Session) handleGetSourceFile(ctx context.Context, params *GetSourceFileParams) (any, error) {

Callers 1

HandleRequestMethod · 0.95

Calls 11

toPathMethod · 0.95
GetDirectoryPathFunction · 0.92
ToAbsoluteFileNameMethod · 0.80
FileNamesMethod · 0.80
GetCurrentDirectoryMethod · 0.65
ReadFileMethod · 0.65
FSMethod · 0.65
ErrorfMethod · 0.65
CompilerOptionsMethod · 0.65

Tested by

no test coverage detected