Angular 11.2+ language service error for inline type constructor not supported by current environment (-998901)

🐞 bug report

Affected Package

@angular/compiler-cli – oob.js
@angular/language-service – ivy.js

Is this a regression?

Worked before in version 11.0.x, and I assume 11.1.x because my Visual Studio Code Extension seems to always update on the latest version of Angular language, and this just started happening in the past week.

Description

I am currently using angular-imask and iMask in my Angular 11 projects. I have not touched any aspect of the usage of these plugins in my code for the past two months, and have not had any unusual Visual Studio Code errors pop up, until now. I’ve started to see the following error appear in both the .ts and .html file of the affected components:

This component uses a directive which requires an inline type constructor, which is not supported by the current environment. (-998901)

I pinpointed it down to the imask directive I use for my input field (assume moneyMask is a valid mask object that has not been changed for the past two months):

<input type="text" id="someId" name="someName" ... [imask]="moneyMask" [unmask]="true" >

If I were to remove the [imask] and [unmask] directives from my input tag, the VSC error goes away for both the affected .ts and .html component files. But now I have effectively eliminated masking from my input fields.

Important: While this error does appear in VSC, I get no issues after running ng lint (I am using ESLint instead of TSLint), and my project both runs fine locally via ng serve and can built without any errors too. So this seems to be centralized with Visual Studio Code and the Angular Language Service, but I know at some point my development team is going to be asking questions soon about this and it could affect any other directive-based plugins I choose to use in my projects.

🌍 Your Environment

Angular Version:


Angular CLI: 11.2.1
Node: 12.20.1
OS: win32 x64

Angular: 11.2.2
... animations, common, compiler, compiler-cli, core, elements
... forms, language-service, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.1
@angular-devkit/build-angular   0.1102.1
@angular-devkit/core            11.2.1
@angular-devkit/schematics      11.2.1
@angular/cdk                    11.2.1
@angular/cli                    11.2.1
@schematics/angular             11.2.1
@schematics/update              0.1102.1
rxjs                            6.6.3
typescript                      4.1.5

Running Visual Studio Code version 1.53.2.
Angular Language Service Extension running version 11.2.3

1 possible answer(s) on “Angular 11.2+ language service error for inline type constructor not supported by current environment (-998901)

  1. @z-svoboda-mob – This is purely a limitation of the language service. The compiler itself will use the correct types during compilation. Some generic directives/components require the compiler to make in-line edits to the source by generating a static method which the type check files can import and use to get the correct type. We can’t make this in-line edit in the language service because that would mean editing the file itself.

    @zarend is addressing this in #41043 – this will be only an informational diagnostic and the language service will use any for the type rather than exiting and providing no information at all.