diff --git a/.pullapprove.yml b/.pullapprove.yml index d4d03bcd3a..c39bb3b61a 100644 --- a/.pullapprove.yml +++ b/.pullapprove.yml @@ -939,6 +939,7 @@ groups: 'docs/SAVED_REPLIES.md', 'docs/TOOLS.md', 'docs/TRIAGE_AND_LABELS.md', + 'goldens/*', 'modules/e2e_util/e2e_util.ts', 'modules/e2e_util/perf_util.ts', 'modules/*', @@ -958,8 +959,6 @@ groups: 'tools/ngcontainer/**', 'tools/npm/**', 'tools/npm_integration_test/**', - 'tools/public_api_guard/BUILD.bazel', - 'tools/public_api_guard/public_api_guard.bzl', 'tools/pullapprove/**', 'tools/rxjs/**', 'tools/saucelabs/**', @@ -994,7 +993,7 @@ groups: conditions: - > contains_any_globs(files, [ - 'tools/public_api_guard/**', + 'goldens/public-api/**', 'docs/NAMING.md', 'aio/content/guide/glossary.md', 'aio/content/guide/styleguide.md', diff --git a/goldens/BUILD.bazel b/goldens/BUILD.bazel new file mode 100644 index 0000000000..00320ff634 --- /dev/null +++ b/goldens/BUILD.bazel @@ -0,0 +1,8 @@ +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "public-api", + srcs = glob([ + "public-api/**/*.d.ts", + ]), +) diff --git a/goldens/README.md b/goldens/README.md new file mode 100644 index 0000000000..e0283cd04c --- /dev/null +++ b/goldens/README.md @@ -0,0 +1,11 @@ +### *`public-api/`* + +This directory contains all of the public api goldens for our npm packages we publish +to NPM. These are tested on all PRs and commits as part of the our bazel tests. + +To check or update the public api goldens, run one of the following commands: + +```bash +yarn public-api:check +yarn public-api:update +``` \ No newline at end of file diff --git a/tools/public_api_guard/animations/animations.d.ts b/goldens/public-api/animations/animations.d.ts similarity index 83% rename from tools/public_api_guard/animations/animations.d.ts rename to goldens/public-api/animations/animations.d.ts index f8dce966fe..1c167a632b 100644 --- a/tools/public_api_guard/animations/animations.d.ts +++ b/goldens/public-api/animations/animations.d.ts @@ -14,16 +14,16 @@ export declare type AnimateTimings = { export declare function animation(steps: AnimationMetadata | AnimationMetadata[], options?: AnimationOptions | null): AnimationReferenceMetadata; -export interface AnimationAnimateChildMetadata extends AnimationMetadata { +export declare interface AnimationAnimateChildMetadata extends AnimationMetadata { options: AnimationOptions | null; } -export interface AnimationAnimateMetadata extends AnimationMetadata { +export declare interface AnimationAnimateMetadata extends AnimationMetadata { styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata | null; timings: string | number | AnimateTimings; } -export interface AnimationAnimateRefMetadata extends AnimationMetadata { +export declare interface AnimationAnimateRefMetadata extends AnimationMetadata { animation: AnimationReferenceMetadata; options: AnimationOptions | null; } @@ -32,7 +32,7 @@ export declare abstract class AnimationBuilder { abstract build(animation: AnimationMetadata | AnimationMetadata[]): AnimationFactory; } -export interface AnimationEvent { +export declare interface AnimationEvent { disabled: boolean; element: any; fromState: string; @@ -46,16 +46,16 @@ export declare abstract class AnimationFactory { abstract create(element: any, options?: AnimationOptions): AnimationPlayer; } -export interface AnimationGroupMetadata extends AnimationMetadata { +export declare interface AnimationGroupMetadata extends AnimationMetadata { options: AnimationOptions | null; steps: AnimationMetadata[]; } -export interface AnimationKeyframesSequenceMetadata extends AnimationMetadata { +export declare interface AnimationKeyframesSequenceMetadata extends AnimationMetadata { steps: AnimationStyleMetadata[]; } -export interface AnimationMetadata { +export declare interface AnimationMetadata { type: AnimationMetadataType; } @@ -82,7 +82,7 @@ export declare interface AnimationOptions { }; } -export interface AnimationPlayer { +export declare interface AnimationPlayer { beforeDestroy?: () => any; parentPlayer: AnimationPlayer | null; readonly totalTime: number; @@ -101,7 +101,7 @@ export interface AnimationPlayer { setPosition(position: any /** TODO #9100 */): void; } -export interface AnimationQueryMetadata extends AnimationMetadata { +export declare interface AnimationQueryMetadata extends AnimationMetadata { animation: AnimationMetadata | AnimationMetadata[]; options: AnimationQueryOptions | null; selector: string; @@ -112,22 +112,22 @@ export declare interface AnimationQueryOptions extends AnimationOptions { optional?: boolean; } -export interface AnimationReferenceMetadata extends AnimationMetadata { +export declare interface AnimationReferenceMetadata extends AnimationMetadata { animation: AnimationMetadata | AnimationMetadata[]; options: AnimationOptions | null; } -export interface AnimationSequenceMetadata extends AnimationMetadata { +export declare interface AnimationSequenceMetadata extends AnimationMetadata { options: AnimationOptions | null; steps: AnimationMetadata[]; } -export interface AnimationStaggerMetadata extends AnimationMetadata { +export declare interface AnimationStaggerMetadata extends AnimationMetadata { animation: AnimationMetadata | AnimationMetadata[]; timings: string | number; } -export interface AnimationStateMetadata extends AnimationMetadata { +export declare interface AnimationStateMetadata extends AnimationMetadata { name: string; options?: { params: { @@ -137,7 +137,7 @@ export interface AnimationStateMetadata extends AnimationMetadata { styles: AnimationStyleMetadata; } -export interface AnimationStyleMetadata extends AnimationMetadata { +export declare interface AnimationStyleMetadata extends AnimationMetadata { offset: number | null; styles: '*' | { [key: string]: string | number; @@ -146,7 +146,7 @@ export interface AnimationStyleMetadata extends AnimationMetadata { } | '*'>; } -export interface AnimationTransitionMetadata extends AnimationMetadata { +export declare interface AnimationTransitionMetadata extends AnimationMetadata { animation: AnimationMetadata | AnimationMetadata[]; expr: string | ((fromState: string, toState: string, element?: any, params?: { [key: string]: any; @@ -154,7 +154,7 @@ export interface AnimationTransitionMetadata extends AnimationMetadata { options: AnimationOptions | null; } -export interface AnimationTriggerMetadata extends AnimationMetadata { +export declare interface AnimationTriggerMetadata extends AnimationMetadata { definitions: AnimationMetadata[]; name: string; options: { diff --git a/tools/public_api_guard/animations/browser.d.ts b/goldens/public-api/animations/browser/browser.d.ts similarity index 100% rename from tools/public_api_guard/animations/browser.d.ts rename to goldens/public-api/animations/browser/browser.d.ts diff --git a/tools/public_api_guard/animations/browser/testing.d.ts b/goldens/public-api/animations/browser/testing/testing.d.ts similarity index 100% rename from tools/public_api_guard/animations/browser/testing.d.ts rename to goldens/public-api/animations/browser/testing/testing.d.ts diff --git a/tools/public_api_guard/common/common.d.ts b/goldens/public-api/common/common.d.ts similarity index 98% rename from tools/public_api_guard/common/common.d.ts rename to goldens/public-api/common/common.d.ts index eb758d6045..3cbe877311 100644 --- a/tools/public_api_guard/common/common.d.ts +++ b/goldens/public-api/common/common.d.ts @@ -128,7 +128,7 @@ export declare class JsonPipe implements PipeTransform { transform(value: any): string; } -export interface KeyValue { +export declare interface KeyValue { key: K; value: V; } @@ -165,12 +165,12 @@ export declare class Location { export declare const LOCATION_INITIALIZED: InjectionToken>; -export interface LocationChangeEvent { +export declare interface LocationChangeEvent { state: any; type: string; } -export interface LocationChangeListener { +export declare interface LocationChangeListener { (event: LocationChangeEvent): any; } @@ -362,7 +362,7 @@ export declare enum Plural { Other = 5 } -export interface PopStateEvent { +export declare interface PopStateEvent { pop?: boolean; state?: any; type?: string; diff --git a/tools/public_api_guard/common/http.d.ts b/goldens/public-api/common/http/http.d.ts similarity index 99% rename from tools/public_api_guard/common/http.d.ts rename to goldens/public-api/common/http/http.d.ts index 0f2fa899aa..dc83116d82 100644 --- a/tools/public_api_guard/common/http.d.ts +++ b/goldens/public-api/common/http/http.d.ts @@ -1489,7 +1489,7 @@ export declare class HttpClientXsrfModule { }): ModuleWithProviders; } -export interface HttpDownloadProgressEvent extends HttpProgressEvent { +export declare interface HttpDownloadProgressEvent extends HttpProgressEvent { partialText?: string; type: HttpEventType.DownloadProgress; } @@ -1552,11 +1552,11 @@ export declare class HttpHeaders { set(name: string, value: string | string[]): HttpHeaders; } -export interface HttpInterceptor { +export declare interface HttpInterceptor { intercept(req: HttpRequest, next: HttpHandler): Observable>; } -export interface HttpParameterCodec { +export declare interface HttpParameterCodec { decodeKey(key: string): string; decodeValue(value: string): string; encodeKey(key: string): string; @@ -1575,7 +1575,7 @@ export declare class HttpParams { toString(): string; } -export interface HttpProgressEvent { +export declare interface HttpProgressEvent { loaded: number; total?: number; type: HttpEventType.DownloadProgress | HttpEventType.UploadProgress; @@ -1690,11 +1690,11 @@ export declare abstract class HttpResponseBase { }, defaultStatus?: number, defaultStatusText?: string); } -export interface HttpSentEvent { +export declare interface HttpSentEvent { type: HttpEventType.Sent; } -export interface HttpUploadProgressEvent extends HttpProgressEvent { +export declare interface HttpUploadProgressEvent extends HttpProgressEvent { type: HttpEventType.UploadProgress; } @@ -1705,7 +1705,7 @@ export declare class HttpUrlEncodingCodec implements HttpParameterCodec { encodeValue(value: string): string; } -export interface HttpUserEvent { +export declare interface HttpUserEvent { type: HttpEventType.User; } @@ -1719,7 +1719,7 @@ export declare abstract class HttpXsrfTokenExtractor { } export declare class JsonpClientBackend implements HttpBackend { - constructor(callbackMap: JsonpCallbackContext, document: any); + constructor(callbackMap: ɵangular_packages_common_http_http_b, document: any); handle(req: HttpRequest): Observable>; } diff --git a/tools/public_api_guard/common/http/testing.d.ts b/goldens/public-api/common/http/testing/testing.d.ts similarity index 97% rename from tools/public_api_guard/common/http/testing.d.ts rename to goldens/public-api/common/http/testing/testing.d.ts index 72b5c10bb4..6e896345e2 100644 --- a/tools/public_api_guard/common/http/testing.d.ts +++ b/goldens/public-api/common/http/testing/testing.d.ts @@ -16,7 +16,7 @@ export declare abstract class HttpTestingController { }): void; } -export interface RequestMatch { +export declare interface RequestMatch { method?: string; url?: string; } diff --git a/tools/public_api_guard/common/testing.d.ts b/goldens/public-api/common/testing/testing.d.ts similarity index 97% rename from tools/public_api_guard/common/testing.d.ts rename to goldens/public-api/common/testing/testing.d.ts index 4b3f845e47..cda45d1a1e 100644 --- a/tools/public_api_guard/common/testing.d.ts +++ b/goldens/public-api/common/testing/testing.d.ts @@ -39,7 +39,7 @@ export declare class MockPlatformLocation implements PlatformLocation { replaceState(state: any, title: string, newUrl: string): void; } -export interface MockPlatformLocationConfig { +export declare interface MockPlatformLocationConfig { appBaseHref?: string; startUrl?: string; } diff --git a/tools/public_api_guard/common/upgrade.d.ts b/goldens/public-api/common/upgrade/upgrade.d.ts similarity index 98% rename from tools/public_api_guard/common/upgrade.d.ts rename to goldens/public-api/common/upgrade/upgrade.d.ts index db9f0782de..5176998e00 100644 --- a/tools/public_api_guard/common/upgrade.d.ts +++ b/goldens/public-api/common/upgrade/upgrade.d.ts @@ -64,7 +64,7 @@ export declare class AngularJSUrlCodec implements UrlCodec { export declare const LOCATION_UPGRADE_CONFIGURATION: InjectionToken; -export interface LocationUpgradeConfig { +export declare interface LocationUpgradeConfig { appBaseHref?: string; hashPrefix?: string; serverBaseHref?: string; diff --git a/tools/public_api_guard/compiler_options.d.ts b/goldens/public-api/compiler-cli/compiler_options.d.ts similarity index 100% rename from tools/public_api_guard/compiler_options.d.ts rename to goldens/public-api/compiler-cli/compiler_options.d.ts diff --git a/tools/public_api_guard/error_code.d.ts b/goldens/public-api/compiler-cli/error_code.d.ts similarity index 100% rename from tools/public_api_guard/error_code.d.ts rename to goldens/public-api/compiler-cli/error_code.d.ts diff --git a/tools/public_api_guard/core/core.d.ts b/goldens/public-api/core/core.d.ts similarity index 90% rename from tools/public_api_guard/core/core.d.ts rename to goldens/public-api/core/core.d.ts index d927be91d1..f47b73703b 100644 --- a/tools/public_api_guard/core/core.d.ts +++ b/goldens/public-api/core/core.d.ts @@ -1,20 +1,20 @@ -export interface AbstractType extends Function { +export declare interface AbstractType extends Function { prototype: T; } -export interface AfterContentChecked { +export declare interface AfterContentChecked { ngAfterContentChecked(): void; } -export interface AfterContentInit { +export declare interface AfterContentInit { ngAfterContentInit(): void; } -export interface AfterViewChecked { +export declare interface AfterViewChecked { ngAfterViewChecked(): void; } -export interface AfterViewInit { +export declare interface AfterViewInit { ngAfterViewInit(): void; } @@ -52,13 +52,13 @@ export declare function asNativeElements(debugEls: DebugElement[]): any; export declare function assertPlatform(requiredToken: any): PlatformRef; -export interface Attribute { +export declare interface Attribute { attributeName?: string; } export declare const Attribute: AttributeDecorator; -export interface AttributeDecorator { +export declare interface AttributeDecorator { (name: string): any; new (name: string): Attribute; } @@ -76,17 +76,17 @@ export declare abstract class ChangeDetectorRef { abstract reattach(): void; } -export interface ClassProvider extends ClassSansProvider { +export declare interface ClassProvider extends ClassSansProvider { multi?: boolean; provide: any; } -export interface ClassSansProvider { +export declare interface ClassSansProvider { useClass: Type; } /** @deprecated */ -export interface CollectionChangeRecord extends IterableChangeRecord { +export declare interface CollectionChangeRecord extends IterableChangeRecord { } export declare class Compiler { @@ -113,7 +113,7 @@ export declare type CompilerOptions = { preserveWhitespaces?: boolean; }; -export interface Component extends Directive { +export declare interface Component extends Directive { animations?: any[]; changeDetection?: ChangeDetectionStrategy; encapsulation?: ViewEncapsulation; @@ -130,26 +130,11 @@ export interface Component extends Directive { export declare const Component: ComponentDecorator; -export interface ComponentDecorator { +export declare interface ComponentDecorator { (obj: Component): TypeDecorator; new (obj: Component): Component; } -export declare abstract class ComponentFactory { - abstract get componentType(): Type; - abstract get inputs(): { - propName: string; - templateName: string; - }[]; - abstract get ngContentSelectors(): string[]; - abstract get outputs(): { - propName: string; - templateName: string; - }[]; - abstract get selector(): string; - abstract create(injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: string | any, ngModule?: NgModuleRef): ComponentRef; -} - export declare abstract class ComponentFactoryResolver { abstract resolveComponentFactory(component: Type): ComponentFactory; static NULL: ComponentFactoryResolver; @@ -166,18 +151,18 @@ export declare abstract class ComponentRef { abstract onDestroy(callback: Function): void; } -export interface ConstructorProvider extends ConstructorSansProvider { +export declare interface ConstructorProvider extends ConstructorSansProvider { multi?: boolean; provide: Type; } -export interface ConstructorSansProvider { +export declare interface ConstructorSansProvider { deps?: any[]; } export declare type ContentChild = Query; -export interface ContentChildDecorator { +export declare interface ContentChildDecorator { (selector: Type | Function | string, opts?: { read?: any; static?: boolean; @@ -190,7 +175,7 @@ export interface ContentChildDecorator { export declare type ContentChildren = Query; -export interface ContentChildrenDecorator { +export declare interface ContentChildrenDecorator { (selector: Type | Function | string, opts?: { descendants?: boolean; read?: any; @@ -207,7 +192,7 @@ export declare function createPlatformFactory(parentPlatformFactory: ((extraProv export declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata; -export interface DebugElement extends DebugNode { +export declare interface DebugElement extends DebugNode { readonly attributes: { [key: string]: string | null; }; @@ -240,7 +225,7 @@ export declare class DebugEventListener { constructor(name: string, callback: Function); } -export interface DebugNode { +export declare interface DebugNode { readonly componentInstance: any; readonly context: any; readonly injector: Injector; @@ -282,7 +267,7 @@ export declare const defineInjectable: typeof ɵɵdefineInjectable; export declare function destroyPlatform(): void; -export interface Directive { +export declare interface Directive { exportAs?: string; host?: { [key: string]: string; @@ -299,16 +284,16 @@ export interface Directive { export declare const Directive: DirectiveDecorator; -export interface DirectiveDecorator { +export declare interface DirectiveDecorator { (obj?: Directive): TypeDecorator; new (obj?: Directive): Directive; } -export interface DoBootstrap { +export declare interface DoBootstrap { ngDoBootstrap(appRef: ApplicationRef): void; } -export interface DoCheck { +export declare interface DoCheck { ngDoCheck(): void; } @@ -334,28 +319,28 @@ export declare class EventEmitter extends Subject { subscribe(generatorOrNext?: any, error?: any, complete?: any): Subscription; } -export interface ExistingProvider extends ExistingSansProvider { +export declare interface ExistingProvider extends ExistingSansProvider { multi?: boolean; provide: any; } -export interface ExistingSansProvider { +export declare interface ExistingSansProvider { useExisting: any; } -export interface FactoryProvider extends FactorySansProvider { +export declare interface FactoryProvider extends FactorySansProvider { multi?: boolean; provide: any; } -export interface FactorySansProvider { +export declare interface FactorySansProvider { deps?: any[]; useFactory: Function; } export declare function forwardRef(forwardRefFn: ForwardRefFn): Type; -export interface ForwardRefFn { +export declare interface ForwardRefFn { (): any; } @@ -365,59 +350,59 @@ export declare const getModuleFactory: (id: string) => NgModuleFactory; export declare function getPlatform(): PlatformRef | null; -export interface GetTestability { +export declare interface GetTestability { addToWindow(registry: TestabilityRegistry): void; findTestabilityInTree(registry: TestabilityRegistry, elem: any, findInAncestors: boolean): Testability | null; } -export interface Host { +export declare interface Host { } export declare const Host: HostDecorator; -export interface HostBinding { +export declare interface HostBinding { hostPropertyName?: string; } export declare const HostBinding: HostBindingDecorator; -export interface HostBindingDecorator { +export declare interface HostBindingDecorator { (hostPropertyName?: string): any; new (hostPropertyName?: string): any; } -export interface HostDecorator { +export declare interface HostDecorator { (): any; new (): Host; } -export interface HostListener { +export declare interface HostListener { args?: string[]; eventName?: string; } export declare const HostListener: HostListenerDecorator; -export interface HostListenerDecorator { +export declare interface HostListenerDecorator { (eventName: string, args?: string[]): any; new (eventName: string, args?: string[]): any; } export declare const inject: typeof ɵɵinject; -export interface Inject { +export declare interface Inject { token: any; } export declare const Inject: InjectDecorator; -export interface Injectable { +export declare interface Injectable { providedIn?: Type | 'root' | 'platform' | 'any' | null; } export declare const Injectable: InjectableDecorator; -export interface InjectableDecorator { +export declare interface InjectableDecorator { (): TypeDecorator; (options?: { providedIn: Type | 'root' | 'platform' | 'any' | null; @@ -430,11 +415,11 @@ export interface InjectableDecorator { export declare type InjectableProvider = ValueSansProvider | ExistingSansProvider | StaticClassSansProvider | ConstructorSansProvider | FactorySansProvider | ClassSansProvider; -export interface InjectableType extends Type { +export declare interface InjectableType extends Type { ɵprov: never; } -export interface InjectDecorator { +export declare interface InjectDecorator { (token: any): any; new (token: any): Inject; } @@ -473,31 +458,31 @@ export declare abstract class Injector { export declare const INJECTOR: InjectionToken; -export interface InjectorType extends Type { +export declare interface InjectorType extends Type { ɵinj: never; } -export interface Input { +export declare interface Input { bindingPropertyName?: string; } export declare const Input: InputDecorator; -export interface InputDecorator { +export declare interface InputDecorator { (bindingPropertyName?: string): any; new (bindingPropertyName?: string): any; } export declare function isDevMode(): boolean; -export interface IterableChangeRecord { +export declare interface IterableChangeRecord { readonly currentIndex: number | null; readonly item: V; readonly previousIndex: number | null; readonly trackById: any; } -export interface IterableChanges { +export declare interface IterableChanges { forEachAddedItem(fn: (record: IterableChangeRecord) => void): void; forEachIdentityChange(fn: (record: IterableChangeRecord) => void): void; forEachItem(fn: (record: IterableChangeRecord) => void): void; @@ -507,11 +492,11 @@ export interface IterableChanges { forEachRemovedItem(fn: (record: IterableChangeRecord) => void): void; } -export interface IterableDiffer { +export declare interface IterableDiffer { diff(object: NgIterable | undefined | null): IterableChanges | null; } -export interface IterableDifferFactory { +export declare interface IterableDifferFactory { create(trackByFn?: TrackByFunction): IterableDiffer; supports(objects: any): boolean; } @@ -525,13 +510,13 @@ export declare class IterableDiffers { static extend(factories: IterableDifferFactory[]): StaticProvider; } -export interface KeyValueChangeRecord { +export declare interface KeyValueChangeRecord { readonly currentValue: V | null; readonly key: K; readonly previousValue: V | null; } -export interface KeyValueChanges { +export declare interface KeyValueChanges { forEachAddedItem(fn: (r: KeyValueChangeRecord) => void): void; forEachChangedItem(fn: (r: KeyValueChangeRecord) => void): void; forEachItem(fn: (r: KeyValueChangeRecord) => void): void; @@ -539,14 +524,14 @@ export interface KeyValueChanges { forEachRemovedItem(fn: (r: KeyValueChangeRecord) => void): void; } -export interface KeyValueDiffer { +export declare interface KeyValueDiffer { diff(object: Map): KeyValueChanges | null; diff(object: { [key: string]: V; }): KeyValueChanges | null; } -export interface KeyValueDifferFactory { +export declare interface KeyValueDifferFactory { create(): KeyValueDiffer; supports(objects: any): boolean; } @@ -574,14 +559,14 @@ export declare class ModuleWithComponentFactories { constructor(ngModuleFactory: NgModuleFactory, componentFactories: ComponentFactory[]); } -export interface ModuleWithProviders { +export declare interface ModuleWithProviders { ngModule: Type; providers?: Provider[]; } export declare type NgIterable = Array | Iterable; -export interface NgModule { +export declare interface NgModule { bootstrap?: Array | any[]>; declarations?: Array | any[]>; /** @deprecated */ entryComponents?: Array | any[]>; @@ -595,7 +580,7 @@ export interface NgModule { export declare const NgModule: NgModuleDecorator; -export interface NgModuleDecorator { +export declare interface NgModuleDecorator { (obj?: NgModule): TypeDecorator; new (obj?: NgModule): NgModule; } @@ -647,35 +632,35 @@ export declare class NgZone { export declare const NO_ERRORS_SCHEMA: SchemaMetadata; -export interface OnChanges { +export declare interface OnChanges { ngOnChanges(changes: SimpleChanges): void; } -export interface OnDestroy { +export declare interface OnDestroy { ngOnDestroy(): void; } -export interface OnInit { +export declare interface OnInit { ngOnInit(): void; } -export interface Optional { +export declare interface Optional { } export declare const Optional: OptionalDecorator; -export interface OptionalDecorator { +export declare interface OptionalDecorator { (): any; new (): Optional; } -export interface Output { +export declare interface Output { bindingPropertyName?: string; } export declare const Output: OutputDecorator; -export interface OutputDecorator { +export declare interface OutputDecorator { (bindingPropertyName?: string): any; new (bindingPropertyName?: string): any; } @@ -730,7 +715,7 @@ export declare type ɵɵComponentDefWithMeta = ComponentDef; +}, QueryFields extends string[]> = ɵComponentDef; export declare function ɵɵcomponentHostSyntheticListener(eventName: string, listenerFn: (e?: any) => any, useCapture?: boolean, eventTargetResolver?: GlobalTargetResolver): typeof ɵɵcomponentHostSyntheticListener; @@ -742,13 +727,13 @@ export declare function ɵɵcontainerRefreshStart(index: number): void; export declare function ɵɵcontentQuery(directiveIndex: number, predicate: Type | string[], descend: boolean, read?: any): void; -export declare function ɵɵCopyDefinitionFeature(definition: DirectiveDef | ComponentDef): void; +export declare function ɵɵCopyDefinitionFeature(definition: ɵDirectiveDef | ɵComponentDef): void; export declare const ɵɵdefaultStyleSanitizer: StyleSanitizeFn; export declare function ɵɵdefineComponent(componentDefinition: { type: Type; - selectors?: CssSelectorList; + selectors?: ɵCssSelectorList; decls: number; vars: number; inputs?: { @@ -780,7 +765,7 @@ export declare function ɵɵdefineComponent(componentDefinition: { export declare const ɵɵdefineDirective: (directiveDefinition: { type: Type; - selectors?: CssSelectorList | undefined; + selectors?: ɵCssSelectorList | undefined; inputs?: { [P in keyof T]?: string | [string, string] | undefined; } | undefined; outputs?: { [P_1 in keyof T]?: string | undefined; } | undefined; features?: DirectiveDefFeature[] | undefined; @@ -824,7 +809,7 @@ export declare type ɵɵDirectiveDefWithMeta = DirectiveDef; +}, QueryFields extends string[]> = ɵDirectiveDef; export declare function ɵɵdirectiveInject(token: Type | InjectionToken): T; export declare function ɵɵdirectiveInject(token: Type | InjectionToken, flags: InjectFlags): T; @@ -845,7 +830,7 @@ export declare function ɵɵelementStart(index: number, name: string, attrsIndex export declare function ɵɵembeddedViewEnd(): void; -export declare function ɵɵembeddedViewStart(viewBlockId: number, decls: number, vars: number): RenderFlags; +export declare function ɵɵembeddedViewStart(viewBlockId: number, decls: number, vars: number): ɵRenderFlags; export declare function ɵɵenableBindings(): void; @@ -875,12 +860,12 @@ export declare function ɵɵi18nPostprocess(message: string, replacements?: { export declare function ɵɵi18nStart(index: number, message: string, subTemplateIndex?: number): void; -export declare function ɵɵInheritDefinitionFeature(definition: DirectiveDef | ComponentDef): void; +export declare function ɵɵInheritDefinitionFeature(definition: ɵDirectiveDef | ɵComponentDef): void; export declare function ɵɵinject(token: Type | InjectionToken): T; export declare function ɵɵinject(token: Type | InjectionToken, flags?: InjectFlags): T | null; -export interface ɵɵInjectableDef { +export declare interface ɵɵInjectableDef { factory: (t?: Type) => T; providedIn: InjectorType | 'root' | 'platform' | 'any' | null; token: unknown; @@ -889,7 +874,7 @@ export interface ɵɵInjectableDef { export declare function ɵɵinjectAttribute(attrNameToInject: string): string | null; -export interface ɵɵInjectorDef { +export declare interface ɵɵInjectorDef { factory: () => T; imports: (InjectorType | InjectorTypeWithProviders)[]; providers: (Type | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | any[])[]; @@ -913,9 +898,9 @@ export declare function ɵɵnamespaceSVG(): void; export declare function ɵɵnextContext(level?: number): T; -export declare type ɵɵNgModuleDefWithMeta = NgModuleDef; +export declare type ɵɵNgModuleDefWithMeta = ɵNgModuleDef; -export declare function ɵɵNgOnChangesFeature(definition: DirectiveDef): void; +export declare function ɵɵNgOnChangesFeature(definition: ɵDirectiveDef): void; export declare function ɵɵpipe(index: number, pipeName: string): any; @@ -929,7 +914,7 @@ export declare function ɵɵpipeBind4(index: number, slotOffset: number, v1: any export declare function ɵɵpipeBindV(index: number, slotOffset: number, values: [any, ...any[]]): any; -export declare type ɵɵPipeDefWithMeta = PipeDef; +export declare type ɵɵPipeDefWithMeta = ɵPipeDef; export declare function ɵɵprojection(nodeIndex: number, selectorIndex?: number, attrs?: TAttributes): void; @@ -957,7 +942,7 @@ export declare function ɵɵpropertyInterpolate8(propName: string, prefix: strin export declare function ɵɵpropertyInterpolateV(propName: string, values: any[], sanitizer?: SanitizerFn): typeof ɵɵpropertyInterpolateV; -export declare function ɵɵProvidersFeature(providers: Provider[], viewProviders?: Provider[]): (definition: DirectiveDef) => void; +export declare function ɵɵProvidersFeature(providers: Provider[], viewProviders?: Provider[]): (definition: ɵDirectiveDef) => void; export declare function ɵɵpureFunction0(slotOffset: number, pureFn: () => T, thisArg?: any): T; @@ -1021,7 +1006,7 @@ export declare function ɵɵsanitizeUrlOrResourceUrl(unsafeUrl: any, tag: string /** @deprecated */ export declare function ɵɵselect(index: number): void; -export declare function ɵɵsetComponentScope(type: ComponentType, directives: Type[], pipes: Type[]): void; +export declare function ɵɵsetComponentScope(type: ɵComponentType, directives: Type[], pipes: Type[]): void; export declare function ɵɵsetNgModuleScope(type: any, scope: { declarations?: Type[] | (() => Type[]); @@ -1055,7 +1040,7 @@ export declare function ɵɵstyleMapInterpolate8(prefix: string, v0: any, i0: st export declare function ɵɵstyleMapInterpolateV(values: any[]): void; -export declare function ɵɵstyleProp(prop: string, value: string | number | SafeValue | undefined | null, suffix?: string | null): typeof ɵɵstyleProp; +export declare function ɵɵstyleProp(prop: string, value: string | number | ɵSafeValue | undefined | null, suffix?: string | null): typeof ɵɵstyleProp; export declare function ɵɵstylePropInterpolate1(prop: string, prefix: string, v0: any, suffix: string, valueSuffix?: string | null): typeof ɵɵstylePropInterpolate1; @@ -1079,7 +1064,7 @@ export declare function ɵɵstyleSanitizer(sanitizer: StyleSanitizeFn | null): v export declare function ɵɵtemplate(index: number, templateFn: ComponentTemplate | null, decls: number, vars: number, tagName?: string | null, attrsIndex?: number | null, localRefsIndex?: number | null, localRefExtractor?: LocalRefExtractor): void; -export declare function ɵɵtemplateRefExtractor(tNode: TNode, currentView: LView): ViewEngine_TemplateRef | null; +export declare function ɵɵtemplateRefExtractor(tNode: TNode, currentView: ɵangular_packages_core_core_bp): TemplateRef | null; export declare function ɵɵtext(index: number, value?: string): void; @@ -1103,25 +1088,25 @@ export declare function ɵɵtextInterpolate8(prefix: string, v0: any, i0: string export declare function ɵɵtextInterpolateV(values: any[]): typeof ɵɵtextInterpolateV; -export declare function ɵɵupdateSyntheticHostBinding(propName: string, value: T | NO_CHANGE, sanitizer?: SanitizerFn | null): typeof ɵɵupdateSyntheticHostBinding; +export declare function ɵɵupdateSyntheticHostBinding(propName: string, value: T | ɵNO_CHANGE, sanitizer?: SanitizerFn | null): typeof ɵɵupdateSyntheticHostBinding; export declare function ɵɵviewQuery(predicate: Type | string[], descend: boolean, read?: any): void; export declare const PACKAGE_ROOT_URL: InjectionToken; -export interface Pipe { +export declare interface Pipe { name: string; pure?: boolean; } export declare const Pipe: PipeDecorator; -export interface PipeDecorator { +export declare interface PipeDecorator { (obj: Pipe): TypeDecorator; new (obj: Pipe): Pipe; } -export interface PipeTransform { +export declare interface PipeTransform { transform(value: any, ...args: any[]): any; } @@ -1140,13 +1125,13 @@ export declare class PlatformRef { onDestroy(callback: () => void): void; } -export interface Predicate { +export declare interface Predicate { (value: T): boolean; } export declare type Provider = TypeProvider | ValueProvider | ClassProvider | ConstructorProvider | ExistingProvider | FactoryProvider | any[]; -export interface Query { +export declare interface Query { descendants: boolean; first: boolean; isViewQuery: boolean; @@ -1241,7 +1226,7 @@ export declare enum RendererStyleFlags2 { DashCase = 2 } -export interface RendererType2 { +export declare interface RendererType2 { data: { [kind: string]: any; }; @@ -1251,14 +1236,14 @@ export interface RendererType2 { } export declare class ResolvedReflectiveFactory { - dependencies: ReflectiveDependency[]; + dependencies: ɵangular_packages_core_core_e[]; factory: Function; constructor( factory: Function, - dependencies: ReflectiveDependency[]); + dependencies: ɵangular_packages_core_core_e[]); } -export interface ResolvedReflectiveProvider { +export declare interface ResolvedReflectiveProvider { key: ReflectiveKey; multiProvider: boolean; resolvedFactories: ResolvedReflectiveFactory[]; @@ -1271,7 +1256,7 @@ export declare abstract class Sanitizer { static ɵprov: never; } -export interface SchemaMetadata { +export declare interface SchemaMetadata { name: string; } @@ -1284,12 +1269,12 @@ export declare enum SecurityContext { RESOURCE_URL = 5 } -export interface Self { +export declare interface Self { } export declare const Self: SelfDecorator; -export interface SelfDecorator { +export declare interface SelfDecorator { (): any; new (): Self; } @@ -1304,26 +1289,26 @@ export declare class SimpleChange { isFirstChange(): boolean; } -export interface SimpleChanges { +export declare interface SimpleChanges { [propName: string]: SimpleChange; } -export interface SkipSelf { +export declare interface SkipSelf { } export declare const SkipSelf: SkipSelfDecorator; -export interface SkipSelfDecorator { +export declare interface SkipSelfDecorator { (): any; new (): SkipSelf; } -export interface StaticClassProvider extends StaticClassSansProvider { +export declare interface StaticClassProvider extends StaticClassSansProvider { multi?: boolean; provide: any; } -export interface StaticClassSansProvider { +export declare interface StaticClassSansProvider { deps: any[]; useClass: Type; } @@ -1368,7 +1353,7 @@ export declare class TestabilityRegistry { unregisterApplication(token: any): void; } -export interface TrackByFunction { +export declare interface TrackByFunction { (index: number, item: T): any; } @@ -1378,20 +1363,20 @@ export declare const TRANSLATIONS_FORMAT: InjectionToken; export declare const Type: FunctionConstructor; -export interface TypeDecorator { +export declare interface TypeDecorator { (target: Object, propertyKey?: string | symbol, parameterIndex?: number): void; >(type: T): T; } -export interface TypeProvider extends Type { +export declare interface TypeProvider extends Type { } -export interface ValueProvider extends ValueSansProvider { +export declare interface ValueProvider extends ValueSansProvider { multi?: boolean; provide: any; } -export interface ValueSansProvider { +export declare interface ValueSansProvider { useValue: any; } @@ -1407,7 +1392,7 @@ export declare const VERSION: Version; export declare type ViewChild = Query; -export interface ViewChildDecorator { +export declare interface ViewChildDecorator { (selector: Type | Function | string, opts?: { read?: any; static?: boolean; @@ -1420,7 +1405,7 @@ export interface ViewChildDecorator { export declare type ViewChildren = Query; -export interface ViewChildrenDecorator { +export declare interface ViewChildrenDecorator { (selector: Type | Function | string, opts?: { read?: any; }): any; diff --git a/tools/public_api_guard/global_utils.d.ts b/goldens/public-api/core/global_utils.d.ts similarity index 100% rename from tools/public_api_guard/global_utils.d.ts rename to goldens/public-api/core/global_utils.d.ts diff --git a/tools/public_api_guard/core/testing.d.ts b/goldens/public-api/core/testing/testing.d.ts similarity index 98% rename from tools/public_api_guard/core/testing.d.ts rename to goldens/public-api/core/testing/testing.d.ts index e443062de5..634bcffbc9 100644 --- a/tools/public_api_guard/core/testing.d.ts +++ b/goldens/public-api/core/testing/testing.d.ts @@ -47,7 +47,7 @@ export declare type MetadataOverride = { export declare function resetFakeAsyncZone(): void; -export interface TestBed { +export declare interface TestBed { ngModule: Type | Type[]; platform: PlatformRef; compileComponents(): Promise; @@ -86,7 +86,7 @@ export interface TestBed { export declare const TestBed: TestBedStatic; -export interface TestBedStatic { +export declare interface TestBedStatic { new (...args: any[]): TestBed; compileComponents(): Promise; configureCompiler(config: { diff --git a/tools/public_api_guard/elements/elements.d.ts b/goldens/public-api/elements/elements.d.ts similarity index 82% rename from tools/public_api_guard/elements/elements.d.ts rename to goldens/public-api/elements/elements.d.ts index d66c64397e..04f108ca60 100644 --- a/tools/public_api_guard/elements/elements.d.ts +++ b/goldens/public-api/elements/elements.d.ts @@ -8,17 +8,17 @@ export declare abstract class NgElement extends HTMLElement { abstract disconnectedCallback(): void; } -export interface NgElementConfig { +export declare interface NgElementConfig { injector: Injector; strategyFactory?: NgElementStrategyFactory; } -export interface NgElementConstructor

{ +export declare interface NgElementConstructor

{ readonly observedAttributes: string[]; new (injector?: Injector): NgElement & WithProperties

; } -export interface NgElementStrategy { +export declare interface NgElementStrategy { events: Observable; connect(element: HTMLElement): void; disconnect(): void; @@ -26,12 +26,12 @@ export interface NgElementStrategy { setInputValue(propName: string, value: string): void; } -export interface NgElementStrategyEvent { +export declare interface NgElementStrategyEvent { name: string; value: any; } -export interface NgElementStrategyFactory { +export declare interface NgElementStrategyFactory { create(injector: Injector): NgElementStrategy; } diff --git a/tools/public_api_guard/forms/forms.d.ts b/goldens/public-api/forms/forms.d.ts similarity index 97% rename from tools/public_api_guard/forms/forms.d.ts rename to goldens/public-api/forms/forms.d.ts index fa6a25659d..7166895181 100644 --- a/tools/public_api_guard/forms/forms.d.ts +++ b/goldens/public-api/forms/forms.d.ts @@ -86,7 +86,7 @@ export declare abstract class AbstractControlDirective { reset(value?: any): void; } -export interface AbstractControlOptions { +export declare interface AbstractControlOptions { asyncValidators?: AsyncValidatorFn | AsyncValidatorFn[] | null; updateOn?: 'change' | 'blur' | 'submit'; validators?: ValidatorFn | ValidatorFn[] | null; @@ -102,11 +102,11 @@ export declare class AbstractFormGroupDirective extends ControlContainer impleme ngOnInit(): void; } -export interface AsyncValidator extends Validator { +export declare interface AsyncValidator extends Validator { validate(control: AbstractControl): Promise | Observable; } -export interface AsyncValidatorFn { +export declare interface AsyncValidatorFn { (control: AbstractControl): Promise | Observable; } @@ -132,7 +132,7 @@ export declare abstract class ControlContainer extends AbstractControlDirective get path(): string[] | null; } -export interface ControlValueAccessor { +export declare interface ControlValueAccessor { registerOnChange(fn: any): void; registerOnTouched(fn: any): void; setDisabledState?(isDisabled: boolean): void; @@ -155,7 +155,7 @@ export declare class EmailValidator implements Validator { validate(control: AbstractControl): ValidationErrors | null; } -export interface Form { +export declare interface Form { addControl(dir: NgControl): void; addFormGroup(dir: AbstractFormGroupDirective): void; getControl(dir: NgControl): FormControl; @@ -357,11 +357,11 @@ export declare abstract class NgControl extends AbstractControlDirective { abstract viewToModelUpdate(newValue: any): void; } -export declare class NgControlStatus extends AbstractControlStatus { +export declare class NgControlStatus extends ɵangular_packages_forms_forms_g { constructor(cd: NgControl); } -export declare class NgControlStatusGroup extends AbstractControlStatus { +export declare class NgControlStatusGroup extends ɵangular_packages_forms_forms_g { constructor(cd: ControlContainer); } @@ -454,7 +454,7 @@ export declare class RadioControlValueAccessor implements ControlValueAccessor, onChange: () => void; onTouched: () => void; value: any; - constructor(_renderer: Renderer2, _elementRef: ElementRef, _registry: RadioControlRegistry, _injector: Injector); + constructor(_renderer: Renderer2, _elementRef: ElementRef, _registry: ɵangular_packages_forms_forms_n, _injector: Injector); fireUncheck(value: any): void; ngOnDestroy(): void; ngOnInit(): void; @@ -514,12 +514,12 @@ export declare type ValidationErrors = { [key: string]: any; }; -export interface Validator { +export declare interface Validator { registerOnValidatorChange?(fn: () => void): void; validate(control: AbstractControl): ValidationErrors | null; } -export interface ValidatorFn { +export declare interface ValidatorFn { (control: AbstractControl): ValidationErrors | null; } diff --git a/tools/public_api_guard/http/http.d.ts b/goldens/public-api/http/http.d.ts similarity index 95% rename from tools/public_api_guard/http/http.d.ts rename to goldens/public-api/http/http.d.ts index 5651e7289a..432022b995 100644 --- a/tools/public_api_guard/http/http.d.ts +++ b/goldens/public-api/http/http.d.ts @@ -112,13 +112,13 @@ export declare enum ReadyState { } /** @deprecated */ -export declare class Request extends Body { +export declare class Request extends ɵangular_packages_http_http_f { headers: Headers; method: RequestMethod; responseType: ResponseContentType; url: string; withCredentials: boolean; - constructor(requestOptions: RequestArgs); + constructor(requestOptions: ɵangular_packages_http_http_d); detectContentType(): ContentType; detectContentTypeFromBody(): ContentType; getBody(): any; @@ -151,7 +151,7 @@ export declare class RequestOptions { } /** @deprecated */ -export interface RequestOptionsArgs { +export declare interface RequestOptionsArgs { body?: any; headers?: Headers | null; method?: string | RequestMethod | null; @@ -167,7 +167,7 @@ export interface RequestOptionsArgs { } /** @deprecated */ -export declare class Response extends Body { +export declare class Response extends ɵangular_packages_http_http_f { bytesLoaded: number; headers: Headers | null; ok: boolean; @@ -199,7 +199,7 @@ export declare class ResponseOptions { } /** @deprecated */ -export interface ResponseOptionsArgs { +export declare interface ResponseOptionsArgs { body?: string | Object | FormData | ArrayBuffer | Blob | null; headers?: Headers | null; status?: number | null; diff --git a/tools/public_api_guard/http/testing.d.ts b/goldens/public-api/http/testing/testing.d.ts similarity index 100% rename from tools/public_api_guard/http/testing.d.ts rename to goldens/public-api/http/testing/testing.d.ts diff --git a/tools/public_api_guard/localize/localize.d.ts b/goldens/public-api/localize/index.d.ts similarity index 100% rename from tools/public_api_guard/localize/localize.d.ts rename to goldens/public-api/localize/index.d.ts diff --git a/goldens/public-api/localize/init/index.d.ts b/goldens/public-api/localize/init/index.d.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/goldens/public-api/manage.js b/goldens/public-api/manage.js new file mode 100644 index 0000000000..879d429a51 --- /dev/null +++ b/goldens/public-api/manage.js @@ -0,0 +1,54 @@ +const {exec} = require('shelljs'); +const minimist = require('minimist'); + +// Remove all command line flags from the arguments. +const argv = minimist(process.argv.slice(2)); +// The command the user would like to run, either 'accept' or 'test' +const USER_COMMAND = argv._[0]; +// The shell command to query for all Public API guard tests. +const BAZEL_PUBLIC_API_TARGET_QUERY_CMD = + `yarn -s bazel query --output label 'kind(nodejs_test, ...) intersect attr("tags", "api_guard", ...)'` +// Bazel targets for testing Public API goldens +process.stdout.write('Gathering all Public API targets'); +const ALL_PUBLIC_API_TESTS = exec(BAZEL_PUBLIC_API_TARGET_QUERY_CMD, {silent: true}) + .trim() + .split('\n') + .map(test => test.trim()); +process.stdout.clearLine(); +process.stdout.cursorTo(0); +// Bazel targets for generating Public API goldens +const ALL_PUBLIC_API_ACCEPTS = ALL_PUBLIC_API_TESTS.map(test => `${test}.accept`); + +/** + * Run the provided bazel commands on each provided target individually. + */ +function runBazelCommandOnTargets(command, targets, present) { + for (const target of targets) { + process.stdout.write(`${present}: ${target}`); + const commandResult = exec(`yarn -s bazel ${command} ${target}`, {silent: true}); + process.stdout.clearLine(); + process.stdout.cursorTo(0); + if (commandResult.code) { + console.error(`Failed ${command}: ${target}`); + console.group(); + console.error(commandResult.stdout || commandResult.stderr); + console.groupEnd(); + } else { + console.log(`Successful ${command}: ${target}`); + } + } +} + +switch (USER_COMMAND) { + case 'accept': + runBazelCommandOnTargets('run', ALL_PUBLIC_API_ACCEPTS, 'Running'); + break; + case 'test': + runBazelCommandOnTargets('test', ALL_PUBLIC_API_TESTS, 'Testing'); + break; + default: + console.warn('Invalid command provided.'); + console.warn(); + console.warn(`Run this script with either "accept" and "test"`); + break; +} diff --git a/tools/public_api_guard/platform-browser-dynamic/platform-browser-dynamic.d.ts b/goldens/public-api/platform-browser-dynamic/platform-browser-dynamic.d.ts similarity index 100% rename from tools/public_api_guard/platform-browser-dynamic/platform-browser-dynamic.d.ts rename to goldens/public-api/platform-browser-dynamic/platform-browser-dynamic.d.ts diff --git a/tools/public_api_guard/platform-browser-dynamic/testing.d.ts b/goldens/public-api/platform-browser-dynamic/testing/testing.d.ts similarity index 100% rename from tools/public_api_guard/platform-browser-dynamic/testing.d.ts rename to goldens/public-api/platform-browser-dynamic/testing/testing.d.ts diff --git a/tools/public_api_guard/platform-browser/animations.d.ts b/goldens/public-api/platform-browser/animations/animations.d.ts similarity index 100% rename from tools/public_api_guard/platform-browser/animations.d.ts rename to goldens/public-api/platform-browser/animations/animations.d.ts diff --git a/tools/public_api_guard/platform-browser/platform-browser.d.ts b/goldens/public-api/platform-browser/platform-browser.d.ts similarity index 86% rename from tools/public_api_guard/platform-browser/platform-browser.d.ts rename to goldens/public-api/platform-browser/platform-browser.d.ts index 7817c149ac..f38a0e676a 100644 --- a/tools/public_api_guard/platform-browser/platform-browser.d.ts +++ b/goldens/public-api/platform-browser/platform-browser.d.ts @@ -27,10 +27,10 @@ export declare abstract class DomSanitizer implements Sanitizer { export declare function enableDebugTools(ref: ComponentRef): ComponentRef; -export declare const EVENT_MANAGER_PLUGINS: InjectionToken; +export declare const EVENT_MANAGER_PLUGINS: InjectionToken<ɵangular_packages_platform_browser_platform_browser_g[]>; export declare class EventManager { - constructor(plugins: EventManagerPlugin[], _zone: NgZone); + constructor(plugins: ɵangular_packages_platform_browser_platform_browser_g[], _zone: NgZone); addEventListener(element: HTMLElement, eventName: string, handler: Function): Function; addGlobalEventListener(target: string, eventName: string, handler: Function): Function; getZone(): NgZone; @@ -92,22 +92,22 @@ export declare type MetaDefinition = { export declare const platformBrowser: (extraProviders?: StaticProvider[]) => PlatformRef; -export interface SafeHtml extends SafeValue { +export declare interface SafeHtml extends SafeValue { } -export interface SafeResourceUrl extends SafeValue { +export declare interface SafeResourceUrl extends SafeValue { } -export interface SafeScript extends SafeValue { +export declare interface SafeScript extends SafeValue { } -export interface SafeStyle extends SafeValue { +export declare interface SafeStyle extends SafeValue { } -export interface SafeUrl extends SafeValue { +export declare interface SafeUrl extends SafeValue { } -export interface SafeValue { +export declare interface SafeValue { } export declare type StateKey = string & { diff --git a/tools/public_api_guard/platform-browser/testing.d.ts b/goldens/public-api/platform-browser/testing/testing.d.ts similarity index 100% rename from tools/public_api_guard/platform-browser/testing.d.ts rename to goldens/public-api/platform-browser/testing/testing.d.ts diff --git a/tools/public_api_guard/platform-server/platform-server.d.ts b/goldens/public-api/platform-server/platform-server.d.ts similarity index 96% rename from tools/public_api_guard/platform-server/platform-server.d.ts rename to goldens/public-api/platform-server/platform-server.d.ts index 479c315e9c..c7c635e5f4 100644 --- a/tools/public_api_guard/platform-server/platform-server.d.ts +++ b/goldens/public-api/platform-server/platform-server.d.ts @@ -2,7 +2,7 @@ export declare const BEFORE_APP_SERIALIZED: InjectionToken<(() => void | Promise export declare const INITIAL_CONFIG: InjectionToken; -export interface PlatformConfig { +export declare interface PlatformConfig { document?: string; url?: string; } diff --git a/tools/public_api_guard/platform-server/testing.d.ts b/goldens/public-api/platform-server/testing/testing.d.ts similarity index 100% rename from tools/public_api_guard/platform-server/testing.d.ts rename to goldens/public-api/platform-server/testing/testing.d.ts diff --git a/tools/public_api_guard/platform-webworker-dynamic/platform-webworker-dynamic.d.ts b/goldens/public-api/platform-webworker-dynamic/platform-webworker-dynamic.d.ts similarity index 100% rename from tools/public_api_guard/platform-webworker-dynamic/platform-webworker-dynamic.d.ts rename to goldens/public-api/platform-webworker-dynamic/platform-webworker-dynamic.d.ts diff --git a/tools/public_api_guard/platform-webworker/platform-webworker.d.ts b/goldens/public-api/platform-webworker/platform-webworker.d.ts similarity index 95% rename from tools/public_api_guard/platform-webworker/platform-webworker.d.ts rename to goldens/public-api/platform-webworker/platform-webworker.d.ts index cdb0e2fcba..7f6d2ac8ed 100644 --- a/tools/public_api_guard/platform-webworker/platform-webworker.d.ts +++ b/goldens/public-api/platform-webworker/platform-webworker.d.ts @@ -27,14 +27,14 @@ export declare abstract class MessageBus implements MessageBusSource, MessageBus } /** @deprecated */ -export interface MessageBusSink { +export declare interface MessageBusSink { attachToZone(zone: NgZone): void; initChannel(channel: string, runInZone: boolean): void; to(channel: string): EventEmitter; } /** @deprecated */ -export interface MessageBusSource { +export declare interface MessageBusSource { attachToZone(zone: NgZone): void; from(channel: string): EventEmitter; initChannel(channel: string, runInZone: boolean): void; @@ -47,7 +47,7 @@ export declare const platformWorkerApp: (extraProviders?: StaticProvider[] | und export declare const platformWorkerUi: (extraProviders?: StaticProvider[] | undefined) => import("@angular/core").PlatformRef; /** @deprecated */ -export interface ReceivedMessage { +export declare interface ReceivedMessage { args: any[]; id: string; method: string; diff --git a/tools/public_api_guard/router/router.d.ts b/goldens/public-api/router/router.d.ts similarity index 96% rename from tools/public_api_guard/router/router.d.ts rename to goldens/public-api/router/router.d.ts index cb6db66157..58fda6ec47 100644 --- a/tools/public_api_guard/router/router.d.ts +++ b/goldens/public-api/router/router.d.ts @@ -51,19 +51,19 @@ export declare class ActivationStart { toString(): string; } -export interface CanActivate { +export declare interface CanActivate { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree; } -export interface CanActivateChild { +export declare interface CanActivateChild { canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree; } -export interface CanDeactivate { +export declare interface CanDeactivate { canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable | Promise | boolean | UrlTree; } -export interface CanLoad { +export declare interface CanLoad { canLoad(route: Route, segments: UrlSegment[]): Observable | Promise | boolean; } @@ -108,7 +108,7 @@ export declare type DetachedRouteHandle = {}; export declare type Event = RouterEvent | RouteConfigLoadStart | RouteConfigLoadEnd | ChildActivationStart | ChildActivationEnd | ActivationStart | ActivationEnd | Scroll; -export interface ExtraOptions { +export declare interface ExtraOptions { anchorScrolling?: 'disabled' | 'enabled'; enableTracing?: boolean; errorHandler?: ErrorHandler; @@ -192,7 +192,7 @@ export declare class NavigationError extends RouterEvent { toString(): string; } -export interface NavigationExtras { +export declare interface NavigationExtras { fragment?: string; preserveFragment?: boolean; /** @deprecated */ preserveQueryParams?: boolean; @@ -235,7 +235,7 @@ export declare class OutletContext { route: ActivatedRoute | null; } -export interface ParamMap { +export declare interface ParamMap { readonly keys: string[]; get(name: string): string | null; getAll(name: string): string[]; @@ -260,7 +260,7 @@ export declare function provideRoutes(routes: Routes): any; export declare type QueryParamsHandling = 'merge' | 'preserve' | ''; -export interface Resolve { +export declare interface Resolve { resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | T; } @@ -290,7 +290,7 @@ export declare class ResolveStart extends RouterEvent { toString(): string; } -export interface Route { +export declare interface Route { canActivate?: any[]; canActivateChild?: any[]; canDeactivate?: any[]; @@ -456,12 +456,12 @@ export declare class RouterPreloader implements OnDestroy { setUpPreloading(): void; } -export declare class RouterState extends Tree { +export declare class RouterState extends ɵangular_packages_router_router_m { snapshot: RouterStateSnapshot; toString(): string; } -export declare class RouterStateSnapshot extends Tree { +export declare class RouterStateSnapshot extends ɵangular_packages_router_router_m { url: string; toString(): string; } diff --git a/tools/public_api_guard/router/testing.d.ts b/goldens/public-api/router/testing/testing.d.ts similarity index 100% rename from tools/public_api_guard/router/testing.d.ts rename to goldens/public-api/router/testing/testing.d.ts diff --git a/tools/public_api_guard/router/upgrade.d.ts b/goldens/public-api/router/upgrade/upgrade.d.ts similarity index 100% rename from tools/public_api_guard/router/upgrade.d.ts rename to goldens/public-api/router/upgrade/upgrade.d.ts diff --git a/tools/public_api_guard/service-worker/config.d.ts b/goldens/public-api/service-worker/config/config.d.ts similarity index 86% rename from tools/public_api_guard/service-worker/config.d.ts rename to goldens/public-api/service-worker/config/config.d.ts index 5e2902abce..427371c292 100644 --- a/tools/public_api_guard/service-worker/config.d.ts +++ b/goldens/public-api/service-worker/config/config.d.ts @@ -1,4 +1,4 @@ -export interface AssetGroup { +export declare interface AssetGroup { installMode?: 'prefetch' | 'lazy'; name: string; resources: { @@ -8,7 +8,7 @@ export interface AssetGroup { updateMode?: 'prefetch' | 'lazy'; } -export interface Config { +export declare interface Config { appData?: {}; assetGroups?: AssetGroup[]; dataGroups?: DataGroup[]; @@ -16,7 +16,7 @@ export interface Config { navigationUrls?: string[]; } -export interface DataGroup { +export declare interface DataGroup { cacheConfig: { maxSize: number; maxAge: Duration; @@ -30,7 +30,7 @@ export interface DataGroup { export declare type Duration = string; -export interface Filesystem { +export declare interface Filesystem { hash(file: string): Promise; list(dir: string): Promise; read(file: string): Promise; diff --git a/tools/public_api_guard/service-worker/service-worker.d.ts b/goldens/public-api/service-worker/service-worker.d.ts similarity index 85% rename from tools/public_api_guard/service-worker/service-worker.d.ts rename to goldens/public-api/service-worker/service-worker.d.ts index 975f331604..097cbe2339 100644 --- a/tools/public_api_guard/service-worker/service-worker.d.ts +++ b/goldens/public-api/service-worker/service-worker.d.ts @@ -12,7 +12,7 @@ export declare class SwPush { }; }>; readonly subscription: Observable; - constructor(sw: NgswCommChannel); + constructor(sw: ɵangular_packages_service_worker_service_worker_a); requestSubscription(options: { serverPublicKey: string; }): Promise; @@ -29,12 +29,12 @@ export declare class SwUpdate { readonly activated: Observable; readonly available: Observable; get isEnabled(): boolean; - constructor(sw: NgswCommChannel); + constructor(sw: ɵangular_packages_service_worker_service_worker_a); activateUpdate(): Promise; checkForUpdate(): Promise; } -export interface UpdateActivatedEvent { +export declare interface UpdateActivatedEvent { current: { hash: string; appData?: Object; @@ -46,7 +46,7 @@ export interface UpdateActivatedEvent { type: 'UPDATE_ACTIVATED'; } -export interface UpdateAvailableEvent { +export declare interface UpdateAvailableEvent { available: { hash: string; appData?: Object; diff --git a/tools/public_api_guard/upgrade/static.d.ts b/goldens/public-api/upgrade/static/static.d.ts similarity index 100% rename from tools/public_api_guard/upgrade/static.d.ts rename to goldens/public-api/upgrade/static/static.d.ts diff --git a/tools/public_api_guard/upgrade/static/testing.d.ts b/goldens/public-api/upgrade/static/testing/testing.d.ts similarity index 100% rename from tools/public_api_guard/upgrade/static/testing.d.ts rename to goldens/public-api/upgrade/static/testing/testing.d.ts diff --git a/tools/public_api_guard/upgrade/upgrade.d.ts b/goldens/public-api/upgrade/upgrade.d.ts similarity index 100% rename from tools/public_api_guard/upgrade/upgrade.d.ts rename to goldens/public-api/upgrade/upgrade.d.ts diff --git a/package.json b/package.json index bcf9901862..5201055ad9 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,9 @@ "circleci-win-ve": "bazel test --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only,-browser:chromium-local //packages/compiler-cli/... //tools/ts-api-guardian/...", "circleci-win-ivy": "bazel test --config=ivy --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot --test_tag_filters=-no-ivy-aot,-fixme-ivy-aot,-browser:chromium-local //packages/compiler-cli/... //tools/ts-api-guardian/...", "lint": "yarn -s tslint && yarn gulp lint", - "tslint": "tsc -p tools/tsconfig.json && tslint -c tslint.json \"+(packages|modules|scripts|tools)/**/*.+(js|ts)\"" + "tslint": "tsc -p tools/tsconfig.json && tslint -c tslint.json \"+(packages|modules|scripts|tools)/**/*.+(js|ts)\"", + "public-api:check": "node goldens/public-api/manage.js test", + "public-api:update": "node goldens/public-api/manage.js accept" }, "// 1": "dependencies are used locally and by bazel", "dependencies": { diff --git a/packages/animations/BUILD.bazel b/packages/animations/BUILD.bazel index cea406c057..e51bab3671 100644 --- a/packages/animations/BUILD.bazel +++ b/packages/animations/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -39,3 +39,13 @@ ng_package( "//packages/animations/browser/testing", ], ) + +ts_api_guardian_test_npm_package( + name = "animations_api", + actualDir = "packages/animations/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/animations", +) diff --git a/packages/common/BUILD.bazel b/packages/common/BUILD.bazel index 57de79d5e4..fd0b213c76 100644 --- a/packages/common/BUILD.bazel +++ b/packages/common/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -51,3 +51,13 @@ ng_package( "//packages/common/upgrade", ], ) + +ts_api_guardian_test_npm_package( + name = "common_api", + actualDir = "packages/common/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/common", +) diff --git a/packages/compiler-cli/BUILD.bazel b/packages/compiler-cli/BUILD.bazel index da5dc1f935..2a4142878d 100644 --- a/packages/compiler-cli/BUILD.bazel +++ b/packages/compiler-cli/BUILD.bazel @@ -1,6 +1,6 @@ package(default_visibility = ["//visibility:public"]) -load("//tools:defaults.bzl", "pkg_npm", "ts_library") +load("//tools:defaults.bzl", "pkg_npm", "ts_api_guardian_test", "ts_library") load("@npm_bazel_typescript//:index.bzl", "ts_config") ts_config( @@ -59,3 +59,23 @@ pkg_npm( "//packages/compiler-cli/ngcc", ], ) + +ts_api_guardian_test( + name = "error_code_api", + actual = "packages/compiler-cli/npm_package/src/ngtsc/diagnostics/src/error_code.d.ts", + data = [ + ":npm_package", + "//goldens:public-api", + ], + golden = "goldens/public-api/compiler-cli/error_code.d.ts", +) + +ts_api_guardian_test( + name = "compiler_options_api", + actual = "packages/compiler-cli/npm_package/src/ngtsc/core/api/src/public_options.d.ts", + data = [ + ":npm_package", + "//goldens:public-api", + ], + golden = "goldens/public-api/compiler-cli/compiler_options.d.ts", +) diff --git a/packages/core/BUILD.bazel b/packages/core/BUILD.bazel index 521f2f00e2..940534a137 100644 --- a/packages/core/BUILD.bazel +++ b/packages/core/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -54,3 +54,23 @@ ng_package( "//packages/core/testing", ], ) + +ts_api_guardian_test_npm_package( + name = "core_api", + actualDir = "packages/core/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/core", +) + +ts_api_guardian_test( + name = "ng_global_utils_api", + actual = "packages/core/src/render3/global_utils_api.d.ts", + data = [ + "//goldens:public-api", + "//packages/core", + ], + golden = "goldens/public-api/core/global_utils.d.ts", +) diff --git a/packages/elements/BUILD.bazel b/packages/elements/BUILD.bazel index 5a7485e54d..94c4c86d4d 100644 --- a/packages/elements/BUILD.bazel +++ b/packages/elements/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -37,3 +37,13 @@ ng_package( ":elements", ], ) + +ts_api_guardian_test_npm_package( + name = "elements_api", + actualDir = "packages/elements/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/elements", +) diff --git a/packages/forms/BUILD.bazel b/packages/forms/BUILD.bazel index b8cff6bb26..5ef1d01416 100644 --- a/packages/forms/BUILD.bazel +++ b/packages/forms/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -37,3 +37,13 @@ ng_package( ":forms", ], ) + +ts_api_guardian_test_npm_package( + name = "forms_api", + actualDir = "packages/forms/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/forms", +) diff --git a/packages/http/BUILD.bazel b/packages/http/BUILD.bazel index 3389830f18..12240ab7d2 100644 --- a/packages/http/BUILD.bazel +++ b/packages/http/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -42,3 +42,13 @@ ng_package( "//packages/http/testing", ], ) + +ts_api_guardian_test_npm_package( + name = "http_api", + actualDir = "packages/http/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/http", +) diff --git a/packages/localize/BUILD.bazel b/packages/localize/BUILD.bazel index b81d1ad48d..057ff08a6f 100644 --- a/packages/localize/BUILD.bazel +++ b/packages/localize/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_package", "ts_library") +load("//tools:defaults.bzl", "ng_package", "ts_api_guardian_test_npm_package", "ts_library") package(default_visibility = ["//visibility:public"]) @@ -36,3 +36,13 @@ ng_package( "//packages/localize/init", ], ) + +ts_api_guardian_test_npm_package( + name = "localize_api", + actualDir = "packages/localize/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/localize", +) diff --git a/packages/platform-browser-dynamic/BUILD.bazel b/packages/platform-browser-dynamic/BUILD.bazel index 51ce60e473..6be1cb4864 100644 --- a/packages/platform-browser-dynamic/BUILD.bazel +++ b/packages/platform-browser-dynamic/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -40,3 +40,13 @@ ng_package( "//packages/platform-browser-dynamic/testing", ], ) + +ts_api_guardian_test_npm_package( + name = "platform-browser-dynamic_api", + actualDir = "packages/platform-browser-dynamic/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/platform-browser-dynamic", +) diff --git a/packages/platform-browser/BUILD.bazel b/packages/platform-browser/BUILD.bazel index 1a7426fcd3..1ca1740b23 100644 --- a/packages/platform-browser/BUILD.bazel +++ b/packages/platform-browser/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -43,3 +43,13 @@ ng_package( "//packages/platform-browser/testing", ], ) + +ts_api_guardian_test_npm_package( + name = "platform-browser_api", + actualDir = "packages/platform-browser/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/platform-browser", +) diff --git a/packages/platform-server/BUILD.bazel b/packages/platform-server/BUILD.bazel index b4eea7c681..b6c4820fff 100644 --- a/packages/platform-server/BUILD.bazel +++ b/packages/platform-server/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -46,3 +46,13 @@ ng_package( "//packages/platform-server/testing", ], ) + +ts_api_guardian_test_npm_package( + name = "platform-server_api", + actualDir = "packages/platform-server/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/platform-server", +) diff --git a/packages/platform-webworker-dynamic/BUILD.bazel b/packages/platform-webworker-dynamic/BUILD.bazel index 3b792fc76c..44d2a5c8ea 100644 --- a/packages/platform-webworker-dynamic/BUILD.bazel +++ b/packages/platform-webworker-dynamic/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -31,3 +31,13 @@ ng_package( visibility = ["//integration:__pkg__"], deps = [":platform-webworker-dynamic"], ) + +ts_api_guardian_test_npm_package( + name = "platform-webworker-dynamic_api", + actualDir = "packages/platform-webworker-dynamic/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/platform-webworker-dynamic", +) diff --git a/packages/platform-webworker/BUILD.bazel b/packages/platform-webworker/BUILD.bazel index a6d8452e53..bb3156484f 100644 --- a/packages/platform-webworker/BUILD.bazel +++ b/packages/platform-webworker/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -37,3 +37,13 @@ ng_package( ":platform-webworker", ], ) + +ts_api_guardian_test_npm_package( + name = "platform-webworker_api", + actualDir = "packages/platform-webworker/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/platform-webworker", +) diff --git a/packages/router/BUILD.bazel b/packages/router/BUILD.bazel index 4ad99cde1c..4e8e1cb96f 100644 --- a/packages/router/BUILD.bazel +++ b/packages/router/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -43,3 +43,13 @@ ng_package( "//packages/router/upgrade", ], ) + +ts_api_guardian_test_npm_package( + name = "router_api", + actualDir = "packages/router/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/router", +) diff --git a/packages/service-worker/BUILD.bazel b/packages/service-worker/BUILD.bazel index 434e3638f1..8fb353c274 100644 --- a/packages/service-worker/BUILD.bazel +++ b/packages/service-worker/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -58,3 +58,13 @@ ng_package( "//packages/service-worker/config", ], ) + +ts_api_guardian_test_npm_package( + name = "service-worker_api", + actualDir = "packages/service-worker/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/service-worker", +) diff --git a/packages/upgrade/BUILD.bazel b/packages/upgrade/BUILD.bazel index e4716db331..4b23d7dc8c 100644 --- a/packages/upgrade/BUILD.bazel +++ b/packages/upgrade/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package") +load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") package(default_visibility = ["//visibility:public"]) @@ -38,3 +38,13 @@ ng_package( "//packages/upgrade/static/testing", ], ) + +ts_api_guardian_test_npm_package( + name = "upgrade_api", + actualDir = "packages/upgrade/npm_package", + data = [ + ":npm_package", + "//goldens:public-api", + ], + goldenDir = "goldens/public-api/upgrade", +) diff --git a/tools/defaults.bzl b/tools/defaults.bzl index d9255a9f41..a6f7fa2569 100644 --- a/tools/defaults.bzl +++ b/tools/defaults.bzl @@ -12,6 +12,7 @@ load("@npm//typescript:index.bzl", "tsc") load("//packages/bazel:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package") load("//tools/ng_rollup_bundle:ng_rollup_bundle.bzl", _ng_rollup_bundle = "ng_rollup_bundle") load("//tools:ng_benchmark.bzl", _ng_benchmark = "ng_benchmark") +load("//tools/ts-api-guardian:index.bzl", _ts_api_guardian_test = "ts_api_guardian_test", _ts_api_guardian_test_npm_package = "ts_api_guardian_test_npm_package") _DEFAULT_TSCONFIG_TEST = "//packages:tsconfig-test" _INTERNAL_NG_MODULE_API_EXTRACTOR = "//packages/bazel/src/api-extractor:api_extractor" @@ -459,3 +460,19 @@ def rollup_bundle(name, testonly = False, sourcemap = "true", **kwargs): ) terser_minified(name = name + ".min.es5umd", testonly = testonly, src = name + ".es5umd", **common_terser_args) native.filegroup(name = name + ".min.es5umd.js", testonly = testonly, srcs = [name + ".min.es5umd"]) + +def ts_api_guardian_test(**kwargs): + _ts_api_guardian_test( + tags = [ + "fixme-ivy-aot", + ], + **kwargs + ) + +def ts_api_guardian_test_npm_package(**kwargs): + _ts_api_guardian_test_npm_package( + tags = [ + "fixme-ivy-aot", + ], + **kwargs + ) diff --git a/tools/public_api_guard/BUILD.bazel b/tools/public_api_guard/BUILD.bazel deleted file mode 100644 index 81dc44d044..0000000000 --- a/tools/public_api_guard/BUILD.bazel +++ /dev/null @@ -1,91 +0,0 @@ -load("//tools/ts-api-guardian:index.bzl", "ts_api_guardian_test") -load(":public_api_guard.bzl", "generate_targets") - -generate_targets(golden_files = glob( - ["*/**/*.d.ts"], - # exclude the following target because we have an explicit target for it bellow, see :core_api, etc - exclude = [ - "core/core.d.ts", - "upgrade/upgrade.d.ts", - "upgrade/static.d.ts", - ], -)) - -# Explicit target because core is broken down into sub-packages. -# The ts_api_guardian rule does not know how to collect the .d.ts files from the sub-packages so we have to list it here explicitly. -# see: https://github.com/angular/angular/issues/28057 -ts_api_guardian_test( - name = "core_api", - actual = "angular/packages/core/core.d.ts", - data = ["//tools/public_api_guard:core/core.d.ts"] + [ - "//packages/core", - "//packages/core/src/di/interface", - "//packages/core/src/interface", - "//packages/core/src/util", - ], - golden = "angular/tools/public_api_guard/core/core.d.ts", - tags = [ - "fixme-ivy-aot", # ivy no longer emits generated index file - ], -) - -ts_api_guardian_test( - name = "upgrade_api", - actual = "angular/packages/upgrade/upgrade.d.ts", - data = ["//tools/public_api_guard:upgrade/upgrade.d.ts"] + [ - "//packages/upgrade", - "//packages/upgrade/src/common", - ], - golden = "angular/tools/public_api_guard/upgrade/upgrade.d.ts", - tags = [ - "fixme-ivy-aot", # ivy no longer emits generated index file - ], -) - -ts_api_guardian_test( - name = "upgrade_static_api", - actual = "angular/packages/upgrade/static/index.d.ts", - data = ["//tools/public_api_guard:upgrade/static.d.ts"] + [ - "//packages/upgrade/static", - "//packages/upgrade/src/common", - ], - golden = "angular/tools/public_api_guard/upgrade/static.d.ts", - tags = [ - "fixme-ivy-aot", # ivy no longer emits generated index file - ], -) - -# explicit target because the d.ts file is nested in the core and not part of typical public d.ts api -ts_api_guardian_test( - name = "ng_global_utils_api", - actual = "angular/packages/core/src/render3/global_utils_api.d.ts", - data = [ - ":global_utils.d.ts", - "//packages/core", - ], - golden = "angular/tools/public_api_guard/global_utils.d.ts", -) - -# explicit target because the d.ts file is nested in the compiler and not part of typical public -# d.ts api -ts_api_guardian_test( - name = "error_code_api", - actual = "angular/packages/compiler-cli/src/ngtsc/diagnostics/src/error_code.d.ts", - data = [ - ":error_code.d.ts", - "//packages/compiler-cli/src/ngtsc/diagnostics", - ], - golden = "angular/tools/public_api_guard/error_code.d.ts", -) - -# explicit target because the d.ts file is nested in the compiler and not part of typical public -# d.ts api -ts_api_guardian_test( - name = "compiler_options_api", - actual = "angular/packages/compiler-cli/src/ngtsc/core/api/src/public_options.d.ts", - data = [ - ":compiler_options.d.ts", - "//packages/compiler-cli/src/ngtsc/core:api", - ], - golden = "angular/tools/public_api_guard/compiler_options.d.ts", -) diff --git a/tools/public_api_guard/public_api_guard.bzl b/tools/public_api_guard/public_api_guard.bzl deleted file mode 100644 index 5c6c9c6bb0..0000000000 --- a/tools/public_api_guard/public_api_guard.bzl +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright Google Inc. All Rights Reserved. -# -# Use of this source code is governed by an MIT-style license that can be -# found in the LICENSE file at https://angular.io/license - -"""public_api_guard bazel target generator -""" - -load("//tools/ts-api-guardian:index.bzl", "ts_api_guardian_test") - -def generate_targets(golden_files): - """Generates a list of targets to check based on the golden files passed in. - """ - for golden_file in golden_files: - entry_point = golden_file[:-len(".d.ts")] - [package_name, entry_point_tail] = entry_point.split("/", 1) - directory_name = entry_point_tail.split("/")[-1] - target_suffix = "/" + entry_point_tail if package_name != entry_point_tail else "" - actual_file = "angular/packages/%s%s/%s.d.ts" % (package_name, target_suffix, directory_name) - label_name = package_name + target_suffix.replace("/", "_") - - ts_api_guardian_test( - name = "%s_api" % label_name, - actual = actual_file, - data = [golden_file] + [ - "//packages/%s:%s" % (package_name + target_suffix, directory_name), - ], - golden = "angular/tools/public_api_guard/%s" % golden_file, - tags = [ - "fixme-ivy-aot", # ivy no longer emits generated index file - ], - ) diff --git a/tools/ts-api-guardian/index.bzl b/tools/ts-api-guardian/index.bzl index 5a135cf726..521756b82d 100644 --- a/tools/ts-api-guardian/index.bzl +++ b/tools/ts-api-guardian/index.bzl @@ -62,6 +62,7 @@ def ts_api_guardian_test( name = name, data = data, entry_point = "@angular//tools/ts-api-guardian:bin/ts-api-guardian", + tags = kwargs.pop("tags", []) + ["api_guard"], templated_args = args + ["--verify", golden, actual], **kwargs ) @@ -71,6 +72,7 @@ def ts_api_guardian_test( testonly = True, data = data, entry_point = "@angular//tools/ts-api-guardian:bin/ts-api-guardian", + tags = kwargs.pop("tags", []) + ["api_guard"], templated_args = args + ["--out", golden, actual], **kwargs ) @@ -120,8 +122,8 @@ def ts_api_guardian_test_npm_package( name = name, data = data, entry_point = "@angular//tools/ts-api-guardian:bin/ts-api-guardian", - templated_args = args + ["--verifyDir", goldenDir, "--rootDir", actualDir], - tags = ["api_guard"], + tags = kwargs.pop("tags", []) + ["api_guard"], + templated_args = args + ["--autoDiscoverEntrypoints", "--verifyDir", goldenDir, "--rootDir", actualDir], **kwargs ) @@ -130,7 +132,7 @@ def ts_api_guardian_test_npm_package( testonly = True, data = data, entry_point = "@angular//tools/ts-api-guardian:bin/ts-api-guardian", - templated_args = args + ["--outDir", goldenDir, "--rootDir", actualDir], - tags = ["api_guard"], + tags = kwargs.pop("tags", []) + ["api_guard"], + templated_args = args + ["--autoDiscoverEntrypoints", "--outDir", goldenDir, "--rootDir", actualDir], **kwargs ) diff --git a/tools/ts-api-guardian/lib/main.ts b/tools/ts-api-guardian/lib/main.ts index e91f3fbc69..8555d4f9d2 100644 --- a/tools/ts-api-guardian/lib/main.ts +++ b/tools/ts-api-guardian/lib/main.ts @@ -57,7 +57,7 @@ function ensureDirectory(dir: string) { */ function isDirectory(dirPath: string) { try { - fs.lstatSync(dirPath).isDirectory(); + return fs.lstatSync(dirPath).isDirectory(); } catch { return false; }