If I have a.typ and b.typ, can I use #link in a.typ to create a link to b.typ?
As long as you include the file b.typ in the file a.typ links and references will work between the two files. See below for a minimal example with two files:
File a.typ
This is my file `a.typ` with a link to @a-figure in file `b.typ`
#include "b.typ"
File b.typ
This is my file `b.typ` which will be included in `a.typ`
#figure(rect()) <a-figure>
I had such a project, and for conditionally creating a link, I had something like this:
#context if query(<file-b>).len() == 1 { link(<file-b>)[File b] }
#metadata[]<file-b>