angularvisual-studio-codeangular-language-service

Angular langage service not working in vs code for new components generated with the cli


I have an older angular project with a few components already made. The angular language service is not working for NEW components generated with the cli,

New component generated today: HTML then here is the ts file: ts file

however if you look in another component in the same project which was generated a few days ago it works:

[working][1]

ts file: ts file

I thought it was an IVY problem so I went ahead and disables AOT in angular.json and added "enableIvy": false in my ts config, here are those files:

Angular.json

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
        "frontend": {
            "projectType": "application",
            "schematics": {
                "@schematics/angular:component": {
                    "style": "scss"
                }
            },
            "root": "",
            "sourceRoot": "src",
            "prefix": "app",
            "architect": {
                "build": {
                    "builder": "@angular-devkit/build-angular:browser",
                    "options": {
                        "outputPath": "dist/frontend",
                        "index": "src/index.html",
                        "main": "src/main.ts",
                        "polyfills": "src/polyfills.ts",
                        "tsConfig": "tsconfig.app.json",
                        "aot": false,
                        "assets": ["src/favicon.ico", "src/assets"],
                        "styles": [
                            "src/styles.scss",
                            "node_modules/material-design-icons/iconfont/material-icons.css"
                        ],
                        "scripts": []
                    },
                    "configurations": {
                        "production": {
                            "fileReplacements": [
                                {
                                    "replace": "src/environments/environment.ts",
                                    "with": "src/environments/environment.prod.ts"
                                }
                            ],
                            "optimization": true,
                            "outputHashing": "all",
                            "sourceMap": false,
                            "extractCss": true,
                            "namedChunks": false,
                            "extractLicenses": true,
                            "vendorChunk": false,
                            "buildOptimizer": true,
                            "budgets": [
                                {
                                    "type": "initial",
                                    "maximumWarning": "2mb",
                                    "maximumError": "5mb"
                                },
                                {
                                    "type": "anyComponentStyle",
                                    "maximumWarning": "6kb",
                                    "maximumError": "10kb"
                                }
                            ]
                        }
                    }
                },
                "serve": {
                    "builder": "@angular-devkit/build-angular:dev-server",
                    "options": {
                        "browserTarget": "frontend:build"
                    },
                    "configurations": {
                        "production": {
                            "browserTarget": "frontend:build:production"
                        }
                    }
                },
                "extract-i18n": {
                    "builder": "@angular-devkit/build-angular:extract-i18n",
                    "options": {
                        "browserTarget": "frontend:build"
                    }
                },
                "test": {
                    "builder": "@angular-devkit/build-angular:karma",
                    "options": {
                        "main": "src/test.ts",
                        "polyfills": "src/polyfills.ts",
                        "tsConfig": "tsconfig.spec.json",
                        "karmaConfig": "karma.conf.js",
                        "assets": [
                            "src/favicon.ico",
                            "src/assets",
                            {
                                "glob": "**/*",
                                "input": "node_modules/ngx-auth-firebaseui/assets/",
                                "output": "./assets/"
                            }
                        ],
                        "styles": [
                            "src/styles.scss",
                            "node_modules/material-design-icons/iconfont/material-icons.css"
                        ],
                        "scripts": []
                    }
                },
                "lint": {
                    "builder": "@angular-devkit/build-angular:tslint",
                    "options": {
                        "tsConfig": [
                            "tsconfig.app.json",
                            "tsconfig.spec.json",
                            "e2e/tsconfig.json"
                        ],
                        "exclude": ["**/node_modules/**"]
                    }
                },
                "e2e": {
                    "builder": "@angular-devkit/build-angular:protractor",
                    "options": {
                        "protractorConfig": "e2e/protractor.conf.js",
                        "devServerTarget": "frontend:serve"
                    },
                    "configurations": {
                        "production": {
                            "devServerTarget": "frontend:serve:production"
                        }
                    }
                }
            }
        }
    },
    "defaultProject": "frontend"
}

tsconfig.app.json

{
    "extends": "./tsconfig.base.json",
    "compilerOptions": {
        "outDir": "./out-tsc/app",
        "types": []
    },
    "files": ["src/main.ts", "src/polyfills.ts"],
    "include": ["src/**/*.d.ts"],
    "angularCompilerOptions": {
        "enableIvy": false
    }
}

tsconfig.json:

{
  "files": [],
  "references": [
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.spec.json"
    }
]
}

tsconfig.base.json

{
    "compileOnSave": false,
    "compilerOptions": {
        "baseUrl": "./",
        "outDir": "./dist/out-tsc",

        "sourceMap": true,
        "declaration": false,
        "downlevelIteration": true,
        "experimentalDecorators": true,
        "moduleResolution": "node",
        "importHelpers": true,
        "target": "es2015",
        "module": "es2020",
        "lib": ["es2018", "dom"]
    }
}

EDIT
I generated a brand new project from scratch and the problem seems to be limited only to this project. it works fine for NEW components in a NEW project. Just doesn't work in the old one.

When I serve the project I get these warnings which I have never seen or understand, project still compiles though:

WARNING in /Users/raphaelcastro/Documents/Programing/Development/partnerDataEntryProject/frontend/node_modules/@angular/fire/fesm2015/angular-fire-firestore.js depends on '@firebase/app'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

WARNING in /Users/raphaelcastro/Documents/Programing/Development/partnerDataEntryProject/frontend/node_modules/@angular/fire/fesm2015/angular-fire.js depends on 'firebase/app'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

WARNING in /Users/raphaelcastro/Documents/Programing/Development/partnerDataEntryProject/frontend/node_modules/ngx-auth-firebaseui/fesm2015/ngx-auth-firebaseui.js depends on '@firebase/auth'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

WARNING in /Users/raphaelcastro/Documents/Programing/Development/partnerDataEntryProject/frontend/node_modules/@angular/fire/fesm2015/angular-fire-firestore.js depends on '@firebase/firestore'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Solution

  • I had the same issue, it happened after vscode asked me if I want to enable Experimental-ivy and i clicked yes! I had to disable it again after 24 hours of hitting my head against the wall.

    Here's how: How to disable Experimental-ivy