test(compiler): add a public API guard for the public compiler options (#35885)

This commit adds a public API test which guards against unintentional
changes to the accepted keys in `angularCompilerOptions`.

PR Close #35885
This commit is contained in:
Alex Rickabaugh
2020-03-05 13:14:03 -08:00
committed by Matias Niemelä
parent edf881dbf1
commit 983f48136a
4 changed files with 98 additions and 29 deletions

View File

@ -7,7 +7,9 @@
*/
import * as ts from 'typescript';
import {BazelAndG3Options, I18nOptions, LegacyNgcOptions, NgcCompatibilityOptions, StrictTemplateOptions} from './public_options';
import {BazelAndG3Options, I18nOptions, LegacyNgcOptions, MiscOptions, NgcCompatibilityOptions, StrictTemplateOptions} from './public_options';
/**
* Non-public options which are useful during testing of the compiler.
@ -33,32 +35,6 @@ export interface TestOnlyOptions {
* @internal
*/
ivyTemplateTypeCheck?: boolean;
}
/**
* A merged interface of all of the various Angular compiler options, as well as the standard
* `ts.CompilerOptions`.
*
* Also includes a few miscellaneous options.
*/
export interface NgCompilerOptions extends ts.CompilerOptions, LegacyNgcOptions, BazelAndG3Options,
NgcCompatibilityOptions, StrictTemplateOptions, TestOnlyOptions, I18nOptions {
/**
* Whether the compiler should avoid generating code for classes that haven't been exported.
* This is only active when building with `enableIvy: true`. Defaults to `true`.
*/
compileNonExportedClasses?: boolean;
/**
* Whether to remove blank text nodes from compiled templates. It is `false` by default starting
* from Angular 6.
*/
preserveWhitespaces?: boolean;
/**
* Disable TypeScript Version Check.
*/
disableTypeScriptVersionCheck?: boolean;
/** An option to enable ngtsc's internal performance tracing.
*
@ -69,4 +45,13 @@ export interface NgCompilerOptions extends ts.CompilerOptions, LegacyNgcOptions,
* This is currently not exposed to users as the trace format is still unstable.
*/
tracePerformance?: string;
}
}
/**
* A merged interface of all of the various Angular compiler options, as well as the standard
* `ts.CompilerOptions`.
*
* Also includes a few miscellaneous options.
*/
export interface NgCompilerOptions extends ts.CompilerOptions, LegacyNgcOptions, BazelAndG3Options,
NgcCompatibilityOptions, StrictTemplateOptions, TestOnlyOptions, I18nOptions, MiscOptions {}

View File

@ -11,6 +11,8 @@
* compiler for backwards compatibility.
*
* These are expected to be removed at some point in the future.
*
* @publicApi
*/
export interface LegacyNgcOptions {
/** generate all possible generated files */
@ -82,6 +84,8 @@ export interface LegacyNgcOptions {
* existing View Engine applications.
*
* These are expected to be removed at some point in the future.
*
* @publicApi
*/
export interface NgcCompatibilityOptions {
/**
@ -116,6 +120,8 @@ export interface NgcCompatibilityOptions {
/**
* Options related to template type-checking and its strictness.
*
* @publicApi
*/
export interface StrictTemplateOptions {
/**
@ -239,6 +245,8 @@ export interface StrictTemplateOptions {
/**
* Options which control behavior useful for "monorepo" build cases using Bazel (such as the
* internal Google monorepo, g3).
*
* @publicApi
*/
export interface BazelAndG3Options {
/**
@ -280,6 +288,8 @@ export interface BazelAndG3Options {
/**
* Options related to i18n compilation support.
*
* @publicApi
*/
export interface I18nOptions {
/**
@ -304,3 +314,21 @@ export interface I18nOptions {
*/
i18nUseExternalIds?: boolean;
}
/**
* Miscellaneous options that don't fall into any other category
*
* @publicApi
*/
export interface MiscOptions {
/**
* Whether the compiler should avoid generating code for classes that haven't been exported.
* This is only active when building with `enableIvy: true`. Defaults to `true`.
*/
compileNonExportedClasses?: boolean;
/**
* Disable TypeScript Version Check.
*/
disableTypeScriptVersionCheck?: boolean;
}