mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(compiler-cli): add initial compiler options definitions for extended template diagnostics (#44391)
Refs #42966. This includes a mapping of extended template diagnostics to their associated diagnostic category. It is generated from the list of diagnostic names, so the list should always be implicitly kept up to date. Usage looks like: ```json { "angularCompilerOptions": { "extendedDiagnostics": { "checks": { "invalidBananaInBox": "error", "nullishCoalescingNotNullable": "suppress" } } } } ``` PR Close #44391
This commit is contained in:
committed by
Andrew Scott
parent
f8e7f60edf
commit
7dfa44e71a
@@ -10,6 +10,22 @@ export interface BazelAndG3Options {
|
||||
generateDeepReexports?: boolean;
|
||||
}
|
||||
|
||||
// @public
|
||||
export enum DiagnosticCategoryLabel {
|
||||
Error = "error",
|
||||
Suppress = "suppress",
|
||||
Warning = "warning"
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface DiagnosticOptions {
|
||||
extendedDiagnostics?: {
|
||||
checks?: {
|
||||
[Name in ExtendedTemplateDiagnosticName]?: DiagnosticCategoryLabel;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface I18nOptions {
|
||||
enableI18nLegacyMessageIdFormat?: boolean;
|
||||
|
||||
@@ -47,6 +47,7 @@ ts_library(
|
||||
name = "api",
|
||||
srcs = glob(["api/**/*.ts"]),
|
||||
deps = [
|
||||
"//packages/compiler-cli/src/ngtsc/diagnostics",
|
||||
"//packages/compiler-cli/src/ngtsc/file_system",
|
||||
"//packages/compiler-cli/src/ngtsc/shims:api",
|
||||
"@npm//typescript",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import ts from 'typescript';
|
||||
|
||||
import {BazelAndG3Options, I18nOptions, LegacyNgcOptions, MiscOptions, NgcCompatibilityOptions, StrictTemplateOptions, TargetOptions} from './public_options';
|
||||
import {BazelAndG3Options, DiagnosticOptions, I18nOptions, LegacyNgcOptions, MiscOptions, NgcCompatibilityOptions, StrictTemplateOptions, TargetOptions} from './public_options';
|
||||
|
||||
|
||||
/**
|
||||
@@ -53,6 +53,12 @@ export interface InternalOptions {
|
||||
* Also includes a few miscellaneous options.
|
||||
*/
|
||||
export interface NgCompilerOptions extends ts.CompilerOptions, LegacyNgcOptions, BazelAndG3Options,
|
||||
NgcCompatibilityOptions, StrictTemplateOptions,
|
||||
TestOnlyOptions, I18nOptions, TargetOptions,
|
||||
InternalOptions, MiscOptions {}
|
||||
DiagnosticOptions, NgcCompatibilityOptions,
|
||||
StrictTemplateOptions, TestOnlyOptions, I18nOptions,
|
||||
TargetOptions, InternalOptions, MiscOptions {
|
||||
// Replace the index signature type from `ts.CompilerOptions` as it is more strict than it needs
|
||||
// to be and would conflict with some types from the other interfaces. This is ok because Angular
|
||||
// compiler options are actually separate from TS compiler options in the `tsconfig.json` and we
|
||||
// have full control over the structure of Angular's compiler options.
|
||||
[prop: string]: any;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ExtendedTemplateDiagnosticName} from '../../../../ngtsc/diagnostics';
|
||||
|
||||
/**
|
||||
* Options supported by the legacy View Engine compiler, which are still consumed by the Angular Ivy
|
||||
* compiler for backwards compatibility.
|
||||
@@ -258,6 +260,40 @@ export interface StrictTemplateOptions {
|
||||
strictLiteralTypes?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A label referring to a `ts.DiagnosticCategory` or `'suppress'`, meaning the associated diagnostic
|
||||
* should not be displayed at all.
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export enum DiagnosticCategoryLabel {
|
||||
/** Treat the diagnostic as a warning, don't fail the compilation. */
|
||||
Warning = 'warning',
|
||||
|
||||
/** Treat the diagnostic as a hard error, fail the compilation. */
|
||||
Error = 'error',
|
||||
|
||||
/** Ignore the diagnostic altogether. */
|
||||
Suppress = 'suppress',
|
||||
}
|
||||
|
||||
/**
|
||||
* Options which control how diagnostics are emitted from the compiler.
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export interface DiagnosticOptions {
|
||||
/** Options which control how diagnostics are emitted from the compiler. */
|
||||
extendedDiagnostics?: {
|
||||
/**
|
||||
* A map of each extended template diagnostic's name to its category. This can be expanded in
|
||||
* the future with more information for each check or for additional diagnostics not part of the
|
||||
* extended template diagnostics system.
|
||||
*/
|
||||
checks?: {[Name in ExtendedTemplateDiagnosticName]?: DiagnosticCategoryLabel};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Options which control behavior useful for "monorepo" build cases using Bazel (such as the
|
||||
* internal Google monorepo, g3).
|
||||
|
||||
Reference in New Issue
Block a user