Clangd diagnostics inside header file fails when type is defined inside a source file

I have the following project structure:

root/
    api/
        header.hpp
    src/
        main.cpp
    build/
        Makefile
        compile_commands.json
    compile_commands.json -> build/compile_commands.json

/root/api/header.hpp

typedef int t_header;
t_header h_a=6;
t_src h_b = 6; // Unknown type name 't_src'

/root/src/src/main.cpp

typedef int t_src;

#include "header.hpp"

int main(){
   t_src a=5;
   t_header b=5;
}

/root/build/compile_comands.json

[
    {
        "arguments": [
            "c++",
            "-c",
            "-I../api",
            "-o",
            "main.o",
            "../src/main.cpp"
        ],
        "directory": "/home/ineo/test/clangd/build",
        "file": "../src/main.cpp"
    }
]

The issue is that clangd doesn’t recognize t_src typedef inside the header.cpp file. In the clangd logs, I see this: ASTWorker building file /root/api/header.hpp version 0 with command inferred from ../src/main.cpp\n[/build]\n/usr/lib/llvm-12/bin/c++ --driver-mode=g++ -c -I../api /root/api/header.hpp -fsyntax-only -resource-dir=/usr/lib/llvm-12/lib/clang/12.0.1\n'.

It seems to me that even though clangd figures out that header.hpp is using the same flags as main.cpp, it doesn’t look inside the main.cpp file for possible type definitions. Is there any way to change this behavior?

This is a known limitation, please see Support non-self-contained files · Issue #45 · clangd/clangd · GitHub for more details