handleParseConfigFile parses a tsconfig.json file and returns its contents.
(ctx context.Context, params *ParseConfigFileParams)
| 1011 | |
| 1012 | // handleParseConfigFile parses a tsconfig.json file and returns its contents. |
| 1013 | func (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. |
| 1045 | func (s *Session) handleGetSourceFile(ctx context.Context, params *GetSourceFileParams) (any, error) { |
no test coverage detected