Basically, my project structure looks EXACTLY like this official documentation page: https://www.typescriptlang.org/docs/handbook/project-references.html#an-example-project
/
├── src/
│ ├── converter.ts
│ └── units.ts
├── test/
│ ├── converter-tests.ts
│ └── units-tests.ts
└── tsconfig.json
The docs say:
Previously, this structure was rather awkward to work with if you used a single tsconfig file ... Project references can solve all of these problems and more ... The path property of each [project] reference can point to a directory containing a tsconfig.json file, or to the config file itself (which may have any name)
So it says. But to my frustration, the documentation never shows how to use project references to get this structure working, and that's what my project looks like (with one difference I'll mention later*). I'll explicitly list the requirements of the project, although the documentation already implies this information:
/srcshould emit to/lib/testshould emit to/libtest/testts files can import/srcts files/srcts files CAN'T import/testts files/libtestjs files can import/libjs files/libjs files CAN'T import/libtestjs files
Here's the question: How should each tsconfig.json file be written to meet these requirements?
* Here's the one difference that I'd like. This isn't a requirement, simply a nice to have. If your answer doesn't provide a way to do this, that's fine.
The docs show example code like this:
// converter-tests.ts
import * as converter from "../converter";
assert.areEqual(converter.celsiusToFahrenheit(0), 32);
Is it possible to meet all the above requirements but be able to import like this?
// converter-tests.ts
import * as converter from "./converter"; // single dot!!!
assert.areEqual(converter.celsiusToFahrenheit(0), 32);
In other words, src and test are separate directories on the file system, but from tsc and libtest's perspective, they're the same directory. FWIW, this is the default convention for the Java maven build tool.
For that to work, when test ts files import from ./..., its emitted js will import from ../libtest/... I think tsconfig paths might have some role for that, but when considered with the other requirements, it breaks my brain to see how it would be used to pull this off.