π Search Terms
- project references
- tsconfig.json
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about project references.
β― Playground Link
No response
π» Code
Full reduced test case: https://github.com/OliverJAsh/ts-project-references-nested
Contents inlined below.
tsconfig.json:
{
"compilerOptions": {
"outDir": "./dist/"
},
"references": [
{ "path": "./demos/tsconfig.json" },
{ "path": "./app/tsconfig.json" }
]
}
app/tsconfig.json:
{
"compilerOptions": {
"composite": true,
"outDir": "../app-dist/"
},
"include": ["**/*"],
"exclude": ["**/*-demos.*"]
}
app/Component-demos.ts:
// This errors.
import * as helpers from 'demos/helpers';
export const demo = () => {
helpers;
}
demos/tsconfig.json:
{
"compilerOptions": {
"composite": true,
"rootDir": "../",
"outDir": "../demos-dist/",
"paths": {
"demos/*": ["./*"]
}
},
"include": [
"**/*",
"../app/**/*-demos.*"
],
"references": [{ "path": "../app/tsconfig.json" }]
}
demos/helpers.ts:
π Actual behavior
When I run tsc --build --verbose tsconfig.json, there are no errors, but when I open my editor (VS Code) and open the file app/Component-demos.ts, I see errors:
π Expected behavior
No errors inside my editor.
Additional information about the issue
When app/Component-demos.ts is opened, I believe TypeScript traverses parent file directories searching for a tsconfig.json file, and it stops at the first file it finds which in this case is app/tsconfig.json. This TS project does not include the file app/Component-demos.ts, so I believe TypeScript should continue traversing parent file directories to search for another tsconfig.json that does include the file. In this case, we want TypeScript to discover the root tsconfig.json.
π Search Terms
π Version & Regression Information
β― Playground Link
No response
π» Code
Full reduced test case: https://github.com/OliverJAsh/ts-project-references-nested
Contents inlined below.
tsconfig.json:{ "compilerOptions": { "outDir": "./dist/" }, "references": [ { "path": "./demos/tsconfig.json" }, { "path": "./app/tsconfig.json" } ] }app/tsconfig.json:{ "compilerOptions": { "composite": true, "outDir": "../app-dist/" }, "include": ["**/*"], "exclude": ["**/*-demos.*"] }app/Component-demos.ts:demos/tsconfig.json:{ "compilerOptions": { "composite": true, "rootDir": "../", "outDir": "../demos-dist/", "paths": { "demos/*": ["./*"] } }, "include": [ "**/*", "../app/**/*-demos.*" ], "references": [{ "path": "../app/tsconfig.json" }] }demos/helpers.ts:π Actual behavior
When I run
tsc --build --verbose tsconfig.json, there are no errors, but when I open my editor (VS Code) and open the fileapp/Component-demos.ts, I see errors:π Expected behavior
No errors inside my editor.
Additional information about the issue
When
app/Component-demos.tsis opened, I believe TypeScript traverses parent file directories searching for atsconfig.jsonfile, and it stops at the first file it finds which in this case isapp/tsconfig.json. This TS project does not include the fileapp/Component-demos.ts, so I believe TypeScript should continue traversing parent file directories to search for anothertsconfig.jsonthat does include the file. In this case, we want TypeScript to discover the roottsconfig.json.