Error processing request. No Project (tsconfig.json in some subdirectories)
nelson6e65 opened this issue · 2 comments
Context
It's an Angular 12/Ionic 6 project with TypeScript 4.3.
I have different tsconfig.json
files:
tsconfig.json (root)
{
"compileOnSave": false,
"exclude": ["node_modules", "www", "android", "ios", "**/*.spec.ts"],
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"importHelpers": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"target": "es2015",
"module": "es2020",
"lib": ["es2018", "dom"]
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
src/tsconfig.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"outDir": "../out-tsc/app",
"types": ["node", "google.maps"],
"paths": {
"@app/*": ["app/*"],
"@env/*": ["environments/*"],
"@interfaces/*": ["interfaces/*"],
"@directives/*": ["directives/*"],
"@vendor/*": ["vendor/*"]
}
},
"files": ["main.ts", "polyfills.ts"]
}
Description
When I'm on src\app\guards\authenticated.guard.ts
file, it seems like is unable to find the correct tsconfig.json
:
Click to show error logged in console
Error: No Project.
at Object.ThrowNoProject ({PROJECT}\node_modules\typescript\lib\tsserver.js:156265:23)
at IOSession.Session.getFileAndLanguageServiceForSyntacticOperation ({PROJECT}\node_modules\typescript\lib\tsserver.js:164389:42)
at IOSession.Session.getNavigationTree ({PROJECT}\node_modules\typescript\lib\tsserver.js:164745:31)
at Session.handlers.ts.Map.ts.getEntries._a.<computed> ({PROJECT}\node_modules\typescript\lib\tsserver.js:163520:61)
at {PROJECT}\node_modules\typescript\lib\tsserver.js:165210:88
at IOSession.Session.executeWithRequestId ({PROJECT}\node_modules\typescript\lib\tsserver.js:165201:28)
at IOSession.Session.executeCommand ({PROJECT}\node_modules\typescript\lib\tsserver.js:165210:33)
at IOSession.Session.onMessage ({PROJECT}\node_modules\typescript\lib\tsserver.js:165236:35)
at Interface.<anonymous> ({PROJECT}\node_modules\typescript\lib\tsserver.js:167833:31)
at Interface.emit (events.js:223:5)
at Interface._onLine (readline.js:315:10)
at Interface._normalWrite (readline.js:460:12)
at Socket.ondata (readline.js:172:10)
at Socket.emit (events.js:223:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:181:23)
at ln.resolve ({USER}\.atom\packages\atom-typescript\dist\main.js:9:109342)
at vn.onMessage ({USER}\.atom\packages\atom-typescript\dist\main.js:9:110966)
at vn.emit (events.js:223:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at vn.Readable.push (_stream_readable.js:224:10)
at vn.Transform.push (_stream_transform.js:150:32)
at vn._transform ({USER}\.atom\packages\atom-typescript\dist\main.js:9:113361)
at vn.Transform._read (_stream_transform.js:189:10)
at vn.Transform._write (_stream_transform.js:177:12)
at doWrite (_stream_writable.js:435:12)
at writeOrBuffer (_stream_writable.js:419:5)
at vn.Writable.write (_stream_writable.js:309:11)
at un.ondata (_stream_readable.js:728:22)
at un.emit (events.js:223:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at un.Readable.push (_stream_readable.js:224:10)
at un.Transform.push (_stream_transform.js:150:32)
at un._pushBuffer ({USER}\.atom\packages\atom-typescript\dist\main.js:9:108237)
at un._transform ({USER}\.atom\packages\atom-typescript\dist\main.js:9:108067)
at un.Transform._read (_stream_transform.js:189:10)
at un.Transform._write (_stream_transform.js:177:12)
at doWrite (_stream_writable.js:435:12)
at writeOrBuffer (_stream_writable.js:419:5)
at un.Writable.write (_stream_writable.js:309:11)
at Socket.ondata (_stream_readable.js:728:22)
at Socket.emit (events.js:223:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:181:23) "{PROJECT}\src\app\guards\authenticated.guard.ts"
But the weird thing is that, on src\app\auth\guards\guest.guard.ts
file, I don't get that error:
I tried suggestion from #1589 (comment), but it does not work. 😞
Seems like by importing manually that file this error goes away, but is not autocompleted to be imported in another file.
This issue is caused when tsconfig.json
does not include
the specific files (for example, tsconfig.app.jso
does exclude
*.spec.ts files).
Since 3.9 there is a Solution Style:
// tsconfig.json
{
"files": [],
"references": [
{ "path": "./tsconfig.shared.json" },
{ "path": "./tsconfig.frontend.json" },
{ "path": "./tsconfig.backend.json" },
]
}
This file that really does nothing but manage other project files is often called a “solution” in some environments. Here, none of these tsconfig.*.json files get picked up by the server, but we’d really like the language server to understand that the current .ts file probably belongs to one of the mentioned projects in this root tsconfig.json.