TypeScript: Auto import in angular typescript is not working

  • VSCode Version: Version 1.29.1 Typescript 3.1.4

  • OS Version: macOS 10.14.1

Steps to Reproduce:

  1. Create new angular app: ng new app

  2. Add new library: yarn add @datorama/akita

  3. Create session.model.ts:

export interface Session {
  id: ID;
  firstName: string;
  lastName: string;
  token: string;
}

Auto import is not working. I get this error:

[ts] Cannot find name 'ID'. [2304]
any

Starting VSCode with code --disable-extensions didn’t help 😦

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (11 by maintainers)

Most upvoted comments

The same problem occurs even when I try to import some Angular modules. For instance, if I want to autoimport OverlayModule from @angular/cdk, autoimport is not giving any suggestions either 😦.

@mjbvz and @sheetalkamat

I’m having the same issue for Angular Material.

import { NgModule } from '@angular/core';

const modules = [MatButtonModule, MatToolbarModule, MatSidenavModule];

@NgModule({
    declarations: [],
    imports: modules,
    exports: modules,
    providers: []
})
export class MaterialModule {}

The suggestion for MatSidenavModule and the other 2 modules never show up, no light bulb either.

VS Code: 1.29.1 (system setup) Typescript 3.1.6 Windows 10