Imagine having two separate projects, each with its own unique file structure:
/my-projects/
/project-a/
lib.ts
app.ts
tsconfig.json
/project-b/
app.ts // import '../project-a/lib.ts'
tsconfig.json
How can I access and use the lib.ts
file located in project-a
from project-b
without turning it into an NPM module?
Distributing it as an NPM module is not desired, as it is unnecessary for such a simple task. The goal is to simply share one file between both projects.
Attempting to use the code
import '../project-a/lib.ts'
results in TypeScript errors.
'lib.ts' is not under 'rootDir'. 'rootDir' should contain all source files.
- Moving the
tsconfig.json
file up a level to cover bothproject-a
andproject-b
is not feasible due to differing configurations and inconvenience.
Are there any alternative methods to achieve this?