Would someone know how to help to solve a problem of referencing types in a TypeScript monorepo project? Or if it is even possible in the following setting.
The structure is like
.
├── tsconfig.json
├── lib/
│ └── workers/
│ ├── types.ts
│ ├── hello.ts
│ └── tsconfig.json
└── frontend/
├── tsconfig.json
└── openwcMiniflare.ts
where frontend/tsconfig.json references types like import { WorkerMethods, WorkerEvents } from 'workers/types'; with configuration such as (relevant parts, full source here)
{
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"outDir": "./out-tsc",
"sourceMap": true,
"rootDir": "./",
"paths": {
"workers/*": ["../lib/workers/*"]
},
}
"references": [
{ "path": "../lib/workers" }
]
}
workers/types.ts
export type WorkerMethods = {
sum: (x: number, y: number) => number;
mul: (x: number, y: number) => number;
};
export type WorkerEvents = {
ping: string;
};
I don't understand how VS Code gives the following error message and indeed, it looks like the types are undefined during runtime.
BUT! If I change the definition like import { WorkerMethods, WorkerEvents } from '../../lib/workers/types';, then error message tells they're outside of rootDir.
Is structure like this even possible with VS Code?
