Repository: microsoft/TypeScript
File: src/server/session.ts (TypeScript)

Code before:
                })),
            };
        });
    }

    private provideInlayHints(args: protocol.InlayHintsRequestArgs): readonly protocol.InlayHintItem[] {
        const { file, project } = this.getFileAndProject(args);
        const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!;
        const hints = project.getLanguageService().provideInlayHints(file, args, this.getPreferences(file));

        return hints.map(hint => {
            const { position, displayParts } = hint;

            return {
                ...hint,
                position: scriptInfo.positionToLineOffset(position),
                displayParts: displayParts?.map(({ text, span, file }) => {
                    if (span) {
                        const scriptInfo = this.projectService.getScriptInfo(file!)!;

                        return {
                            text,
                            span: {
                                start: scriptInfo.positionToLineOffset(span.start),
                                end: scriptInfo.positionToLineOffset(span.start + span.length),
                                file: file!,
                            },
                        };
                    }
                    else {
                        return { text };
                    }
                }),
            };
        });
    }

    private setCompilerOptionsForInferredProjects(args: protocol.SetCompilerOptionsForInferredProjectsArgs): void {
        this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath);
    }

    private getProjectInfo(args: protocol.ProjectInfoRequestArgs): protocol.ProjectInfo {
        return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList, /*excludeConfigFiles*/ false);
    }

    private getProjectInfoWorker(uncheckedFileName: string, projectFileName: string | undefined, needFileNameList: boolean, excludeConfigFiles: boolean) {
        const { project } = this.getFileAndProjectWorker(uncheckedFileName, projectFileName);
        updateProjectIfDirty(project);
        const projectInfo = {
            configFileName: project.getProjectName(),
            languageServiceDisabled: !project.languageServiceEnabled,

Review comment (bug):
```suggestion
                        Debug.assertIsDefined(file, "target file should be defined");
                        const scriptInfo = this.projectService.getScriptInfo(file)!;

                        return {
                            text,
                            span: {
                                start: scriptInfo.positionToLineOffset(span.start),
                                end: scriptInfo.positionToLineOffset(span.start + span.length),
                                file,
```

Code after:
                })),
            };
        });
    }

    private provideInlayHints(args: protocol.InlayHintsRequestArgs): readonly protocol.InlayHintItem[] {
        const { file, project } = this.getFileAndProject(args);
        const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!;
        const hints = project.getLanguageService().provideInlayHints(file, args, this.getPreferences(file));

        return hints.map(hint => {
            const { position, displayParts } = hint;

            return {
                ...hint,
                position: scriptInfo.positionToLineOffset(position),
                displayParts: displayParts?.map(({ text, span, file }) => {
                    if (span) {
                        Debug.assertIsDefined(file, "Target file should be defined together with its span.");
                        const scriptInfo = this.projectService.getScriptInfo(file)!;

                        return {
                            text,
                            span: {
                                start: scriptInfo.positionToLineOffset(span.start),
                                end: scriptInfo.positionToLineOffset(span.start + span.length),
                                file,
                            },
                        };
                    }
                    else {
                        return { text };
                    }
                }),
            };
        });
    }

    private setCompilerOptionsForInferredProjects(args: protocol.SetCompilerOptionsForInferredProjectsArgs): void {
        this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath);
    }

    private getProjectInfo(args: protocol.ProjectInfoRequestArgs): protocol.ProjectInfo {
        return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList, /*excludeConfigFiles*/ false);
    }

    private getProjectInfoWorker(uncheckedFileName: string, projectFileName: string | undefined, needFileNameList: boolean, excludeConfigFiles: boolean) {
        const { project } = this.getFileAndProjectWorker(uncheckedFileName, projectFileName);
        updateProjectIfDirty(project);
        const projectInfo = {
            configFileName: project.getProjectName(),