/vscode-references-test

Demos vscode's 'Find All References' not working with nx libraries

Primary LanguageTypeScript

vscode-references-test

Install Nx globally

npm install nx --global

Create workspace with an Angular app

npx create-nx-workspace@latest myWorkspaceVscode --preset angular --appName "vscode-references-test" --style "css" --nx-cloud false

Change folder

cd my-workspace-vscode

Add library

nx generate @nrwl/angular:library --name=myLibrary --skipModule

Add data.ts

libs>my-library>src>lib

export interface Todo {
  title: string;
}

Update index.ts

libs>my-library>src>lib

export * from './lib/data';

Update app.component.ts

import { Component } from '@angular/core';
import { Todo } from '@my-workspace-vscode/my-library';

@Component({
  selector: 'my-workspace-vscode-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComponent {
  title = 'vscode-references-test';

  todos: Todo[] = [{ title: 'Todo 1' }, { title: 'Todo 2' }];
}
  • Open workspace with vscode with no editors open.
  • Open libs>my-library>src>lib>data.ts.
  • Right click on Todo and select 'Find All References'.
  • Notice that app.component.ts is not in the results.

Cannot find all references to shared lib's interfaces in VS Code nrwl/nx#3106

fix(language-service): Add resource files as roots to their associate angular/angular#45601