feat(language-service): Add diagnostics to suggest turning on strict mode (#40423)

This PR adds a way for the language server to retrieve compiler options
diagnostics via `languageService.getCompilerOptionsDiagnostics()`.

This will be used by the language server to show a prompt in the editor if
users don't have `strict` or `fullTemplateTypeCheck` turned on.

Ref https://github.com/angular/vscode-ng-language-service/issues/1053

PR Close #40423
This commit is contained in:
Keen Yee Liau
2021-01-13 14:52:29 -08:00
committed by Jessica Janiuk
parent c9fe455fa2
commit ecae75f477
10 changed files with 112 additions and 22 deletions
@@ -127,9 +127,9 @@ export interface StrictTemplateOptions {
/**
* If `true`, implies all template strictness flags below (unless individually disabled).
*
* Has no effect unless `fullTemplateTypeCheck` is also enabled.
* This flag is a superset of `fullTemplateTypeCheck`.
*
* Defaults to `false`, even if "fullTemplateTypeCheck" is set.
* Defaults to `false`, even if "fullTemplateTypeCheck" is `true`.
*/
strictTemplates?: boolean;
@@ -906,7 +906,7 @@ function getR3SymbolsFile(program: ts.Program): ts.SourceFile|null {
/**
* Since "strictTemplates" is a true superset of type checking capabilities compared to
* "strictTemplateTypeCheck", it is required that the latter is not explicitly disabled if the
* "fullTemplateTypeCheck", it is required that the latter is not explicitly disabled if the
* former is enabled.
*/
function verifyCompatibleTypeCheckOptions(options: NgCompilerOptions): ts.Diagnostic|null {
@@ -159,6 +159,16 @@ export enum ErrorCode {
* An injectable already has a `ɵprov` property.
*/
INJECTABLE_DUPLICATE_PROV = 9001,
// 10XXX error codes are reserved for diagnostics with category
// `ts.DiagnosticCategory.Suggestion`. These diagnostics are generated by
// language service.
/**
* Suggest users to enable `strictTemplates` to make use of full capabilities
* provided by Angular language service.
*/
SUGGEST_STRICT_TEMPLATES = 10001,
}
/**