Skip to content

Issues with importing interfaces created with export interface in Angular and TypeScript 3.9.6 #18170

Closed
@stiezinger

Description

@stiezinger

Description

Recently I switched from Angular 9 to 10. On a new project I have issues to import interfaces automatically. For example I want to import this interface to my app.component.ts:


export interface TestInterface {
    string: name;
}

It is located in src/app/testInterface.ts. When i try to import it in my app.component.ts:


test: testInterface;

I am using VSC and IntelliSense is not showing me the option to autoimport/import the interface anymore. When i press Ctrl+. for Quick Fix I receive the message: No code actions available. In Angular 9 with Typescript 3.8.3 everything works fine, IntelliSense shows me the autoimport option or I can import the interface with Ctrl+. Key Binding. If I manually add the import it works:


import { testInterface } from 'src/app/testInterface';

🔬 Reproduction

To reproduce this issue try to install the latest angular/cli (at the moment of writing v10.0.1):


npm i @angular/cli@10.0.1 -g

Then create a new project:


ng new

Name it as you wish, I have enabled routing and choosen CSS for stylesheets.

When you install Angular 9 and create an project:


npm i @angular/cli@9.1.10 -g

ng new

Everything works as it should

🌍 Environment

My Environment is:


    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 10.0.1
Node: 12.18.0
OS: win32 x64

Angular: 10.0.2
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.1
@angular-devkit/build-angular     0.1000.1
@angular-devkit/build-optimizer   0.1000.1
@angular-devkit/build-webpack     0.1000.1
@angular-devkit/core              10.0.1
@angular-devkit/schematics        10.0.1
@angular/cdk                      10.0.1
@angular/cli                      10.0.1
@angular/material                 10.0.1
@ngtools/webpack                  10.0.1
@schematics/angular               10.0.1
@schematics/update                0.1000.1
rxjs                              6.5.5
typescript                        3.9.6
webpack                           4.43.0

Visual Studio Code Version 1.46.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions