I am evaluating a migration to TypeScript for a large code base in an JavaEE environment. There are multiple projects with deep directory structures and JavaScript code that uses global variables etc. across the projects.
TypeScript has multi-project support, illustrated by this small example on GitHub. However, my case is more complex.
(1) JS code is placed deep inside the projects, for example "Project1/src/main/resources/de/mycompany/webapp/ts". The generated JS code should then be place in "Project1/src/main/resources/de/mycompany/webapp/ts-generated". TypeScript offers rootDir and outDir for this purpose.
(2) The folder structure is complex, which is why relative imports are not an option. For example, referencing a file from core project should always be the same - no matter if done from ui project or ui-utils project. TypeScript offers "baseUrl" and "paths" for absolute references. However, this does not seem to work with multi-project setup (or I do something wrong). For example, I want to import * from '@core/utils/mycode.ts'. This reference should be interpreted relative to the core project's baseUrl or rootDir.
(3) I have to make references to existing JS code in global scope. For this purpose, TypeScript offers declaration files (.d.ts) that can be used to give additional type information to the compiler. Thus, I plan to create declaration files for existing JS code. The declarations then have to be imported by consuming TypeScript projects. However, the import-keyword in TypeScript seems to always import declarations as module with a namespace, which contradicts the fact that the JS objects are bound to global scope. I also found Triple-Slash import, which seems to work for relative references but not with absolute references to other projects.
Questions
For (2): Is it possible to have absolute imports across projects, preferably from the baseUrl or rootDir?
For (3): Is it possible to import (or reference) TypeScript declarations from other projects for JS code in global scope. Note that this should not generate any code, it should just tell the compiler about existing code.