-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Current Behavior
VS Code cannot discover references to shared entities that are defined in an nx lib. E.g. in a fresh new angular-nest
nx monorepo VS Code cannot find all references to the Message
interface defined in api-interfaces.ts
. As a consequence, we cannot rename the entity throughout the workspace.
As far as I understood, it happens due to separate Typescript projects we have for apps and libs, and due to the fact, VS Code relies on the Typescript server while identifying references. This issue was described in this Typescript ticket and fixed within this one. It is not reproducible in WebStorm, which perhaps uses another way of reference discovery in a workspace.
That's rather not a bug of nx
per se, but the initial configuration bug/improvement.
Expected Behavior
Find all references and Rename features should work in VS Code throughout all the nx monorepo Typescript subprojects.
To have it working, every nx shared lib should have the following Typescript options enabled:
E.g. in libs/api-interfaces/tsconfig.json
{
...
"compilerOptions": {
...
"composite": true,
"declaration": true
}
}
More details for the composite
option is described here.
Also, we might want to reference lib projects from within application projects. However,
I don't know how beneficial it might be in nx monorepos since it's not required for fixing the current issue.
E.g. in apps/api/tsconfig.json
:
{
..
"references": [
{ "path": "../../libs/api-interfaces" }
]
}
Steps to Reproduce
- Run
npx create-nx-workspace@latest test
. - Select
angular-nest
. - Proceed further with any app name and stylesheet format.
- Open the workspace with VS Code.
- Open
api-interfaces.ts
(this file should be the first and the only file opened after running VS Code). - Find references to the
Message
interface via Shift+F12 or Alt+Shift+F12.
Actual result: no reference found.
Environment
@nrwl/angular : 9.3.0
@nrwl/cli : 9.3.0
@nrwl/cypress : 9.3.0
@nrwl/eslint-plugin-nx : Not Found
@nrwl/express : Not Found
@nrwl/jest : 9.3.0
@nrwl/linter : 9.3.0
@nrwl/nest : 9.3.0
@nrwl/next : Not Found
@nrwl/node : 9.3.0
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 9.3.0
@nrwl/web : Not Found
@nrwl/workspace : 9.3.0
typescript : 3.8.3