Skip to content

Commit 60e403b

Browse files
mheveryjasonaden
authored andcommitted
build: ts-api-guardian should support interface with value types (angular#27223)
This fixes an issue where a value would hide the type. ``` export interface Foo { someMethod(): void; } export const Foo: Function = ...; ``` In the above example the `Foo` constant will hide the `interface Foo` symbol. This change properly saves the interface in addition to the type. PR Close angular#27223
1 parent 23b06af commit 60e403b

File tree

10 files changed

+252
-139
lines changed

10 files changed

+252
-139
lines changed

packages/core/src/metadata/di.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const ANALYZE_FOR_ENTRY_COMPONENTS = new InjectionToken<any>('AnalyzeForE
5050
/**
5151
* Type of the Attribute decorator / constructor function.
5252
*
53-
*
53+
* @publicApi
5454
*/
5555
export interface AttributeDecorator {
5656
/**
@@ -99,6 +99,8 @@ export interface AttributeDecorator {
9999

100100
/**
101101
* Type of the Attribute metadata.
102+
*
103+
* @publicApi
102104
*/
103105
export interface Attribute { attributeName?: string; }
104106

@@ -113,6 +115,8 @@ export const Attribute: AttributeDecorator =
113115

114116
/**
115117
* Type of the Query metadata.
118+
*
119+
* @publicApi
116120
*/
117121
export interface Query {
118122
descendants: boolean;
@@ -181,6 +185,7 @@ export interface ContentChildrenDecorator {
181185
*
182186
*
183187
* @Annotation
188+
* @publicApi
184189
*/
185190
export type ContentChildren = Query;
186191

@@ -237,7 +242,7 @@ export interface ContentChildDecorator {
237242
*
238243
* @see `ContentChild`.
239244
*
240-
*
245+
* @publicApi
241246
*/
242247
export type ContentChild = Query;
243248

@@ -246,6 +251,7 @@ export type ContentChild = Query;
246251
*
247252
*
248253
* @Annotation
254+
*
249255
* @publicApi
250256
*/
251257
export const ContentChild: ContentChildDecorator = makePropDecorator(
@@ -293,6 +299,8 @@ export interface ViewChildrenDecorator {
293299

294300
/**
295301
* Type of the ViewChildren metadata.
302+
*
303+
* @publicApi
296304
*/
297305
export type ViewChildren = Query;
298306

@@ -359,6 +367,8 @@ export interface ViewChildDecorator {
359367

360368
/**
361369
* Type of the ViewChild metadata.
370+
*
371+
* @publicApi
362372
*/
363373
export type ViewChild = Query;
364374

packages/core/src/metadata/directives.ts

+36-89
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,31 @@ export interface DirectiveDecorator {
7777
new (obj: Directive): Directive;
7878
}
7979

80+
/**
81+
* Directive decorator and metadata.
82+
*
83+
* @Annotation
84+
* @publicApi
85+
*/
8086
export interface Directive {
8187
/**
82-
* The CSS selector that triggers the instantiation of a directive.
88+
* The CSS selector that identifies this directive in a template
89+
* and triggers instantiation of the directive.
8390
*
8491
* Declare as one of the following:
8592
*
86-
* - `element-name`: select by element name.
87-
* - `.class`: select by class name.
88-
* - `[attribute]`: select by attribute name.
89-
* - `[attribute=value]`: select by attribute name and value.
90-
* - `:not(sub_selector)`: select only if the element does not match the `sub_selector`.
91-
* - `selector1, selector2`: select if either `selector1` or `selector2` matches.
93+
* - `element-name`: Select by element name.
94+
* - `.class`: Select by class name.
95+
* - `[attribute]`: Select by attribute name.
96+
* - `[attribute=value]`: Select by attribute name and value.
97+
* - `:not(sub_selector)`: Select only if the element does not match the `sub_selector`.
98+
* - `selector1, selector2`: Select if either `selector1` or `selector2` matches.
9299
*
93-
* Angular only allows directives to trigger on CSS selectors that do not cross element
94-
* boundaries. For example, consider a directive with an `input[type=text]` selector.
95-
* For the following HTML, the directive is instantiated only on the
96-
* `<input type="text">` element.
100+
* Angular only allows directives to apply on CSS selectors that do not cross
101+
* element boundaries.
102+
*
103+
* For the following template HTML, a directive with an `input[type=text]` selector,
104+
* would be instantiated only on the `<input type="text">` element.
97105
*
98106
* ```html
99107
* <form>
@@ -176,8 +184,9 @@ export interface Directive {
176184
outputs?: string[];
177185

178186
/**
179-
* A set of injection tokens that allow the DI system to
180-
* provide a dependency to this directive or component.
187+
* Configures the [injector](guide/glossary#injector) of this
188+
* directive or component with a [token](guide/glossary#di-token)
189+
* that maps to a [provider](guide/glossary#provider) of a dependency.
181190
*/
182191
providers?: Provider[];
183192

@@ -247,62 +256,6 @@ export interface Directive {
247256
*/
248257
queries?: {[key: string]: any};
249258

250-
/**
251-
* If true, this directive/component will be skipped by the AOT compiler and so will always be
252-
* compiled using JIT.
253-
*
254-
* This exists to support future Ivy work and has no effect currently.
255-
*/
256-
jit?: true;
257-
}
258-
259-
/**
260-
* Directive decorator and metadata.
261-
*
262-
* @Annotation
263-
*/
264-
export interface Directive {
265-
/**
266-
* The CSS selector that identifies this directive in a template
267-
* and triggers instantiation of the directive.
268-
*
269-
* Declare as one of the following:
270-
*
271-
* - `element-name`: Select by element name.
272-
* - `.class`: Select by class name.
273-
* - `[attribute]`: Select by attribute name.
274-
* - `[attribute=value]`: Select by attribute name and value.
275-
* - `:not(sub_selector)`: Select only if the element does not match the `sub_selector`.
276-
* - `selector1, selector2`: Select if either `selector1` or `selector2` matches.
277-
*
278-
* Angular only allows directives to apply on CSS selectors that do not cross
279-
* element boundaries.
280-
*
281-
* For the following template HTML, a directive with an `input[type=text]` selector,
282-
* would be instantiated only on the `<input type="text">` element.
283-
*
284-
* ```html
285-
* <form>
286-
* <input type="text">
287-
* <input type="radio">
288-
* <form>
289-
* ```
290-
*
291-
*/
292-
selector?: string;
293-
294-
/**
295-
* The set of event-bound output properties.
296-
* When an output property emits an event, an event handler attached
297-
* to that event in the template is invoked.
298-
*
299-
* Each output property maps a `directiveProperty` to a `bindingProperty`:
300-
* - `directiveProperty` specifies the component property that emits events.
301-
* - `bindingProperty` specifies the HTML attribute the event handler is attached to.
302-
*
303-
*/
304-
outputs?: string[];
305-
306259
/**
307260
* Maps class properties to host element bindings for properties,
308261
* attributes, and events, using a set of key-value pairs.
@@ -328,27 +281,12 @@ export interface Directive {
328281
host?: {[key: string]: string};
329282

330283
/**
331-
* Configures the [injector](guide/glossary#injector) of this
332-
* directive or component with a [token](guide/glossary#di-token)
333-
* that maps to a [provider](guide/glossary#provider) of a dependency.
334-
*/
335-
providers?: Provider[];
336-
337-
/**
338-
* The name or names that can be used in the template to assign this directive to a variable.
339-
* For multiple names, use a comma-separated string.
340-
*
341-
*/
342-
exportAs?: string;
343-
344-
/**
345-
* Configures the queries that will be injected into the directive.
346-
*
347-
* Content queries are set before the `ngAfterContentInit` callback is called.
348-
* View queries are set before the `ngAfterViewInit` callback is called.
284+
* If true, this directive/component will be skipped by the AOT compiler and so will always be
285+
* compiled using JIT.
349286
*
287+
* This exists to support future Ivy work and has no effect currently.
350288
*/
351-
queries?: {[key: string]: any};
289+
jit?: true;
352290
}
353291

354292
/**
@@ -512,6 +450,8 @@ export interface ComponentDecorator {
512450

513451
/**
514452
* Supplies configuration metadata for an Angular component.
453+
*
454+
* @publicApi
515455
*/
516456
export interface Component extends Directive {
517457
/**
@@ -645,6 +585,8 @@ export interface PipeDecorator {
645585

646586
/**
647587
* Type of the Pipe metadata.
588+
*
589+
* @publicApi
648590
*/
649591
export interface Pipe {
650592
/**
@@ -704,7 +646,7 @@ export interface InputDecorator {
704646
/**
705647
* Type of metadata for an `Input` property.
706648
*
707-
*
649+
* @publicApi
708650
*/
709651
export interface Input {
710652
/**
@@ -824,6 +766,8 @@ export interface OutputDecorator {
824766

825767
/**
826768
* Type of the Output metadata.
769+
*
770+
* @publicApi
827771
*/
828772
export interface Output { bindingPropertyName?: string; }
829773

@@ -879,6 +823,7 @@ export interface HostBindingDecorator {
879823
/**
880824
* Type of the HostBinding metadata.
881825
*
826+
* @publicApi
882827
*/
883828
export interface HostBinding { hostPropertyName?: string; }
884829

@@ -902,6 +847,8 @@ export interface HostListenerDecorator {
902847

903848
/**
904849
* Type of the HostListener metadata.
850+
*
851+
* @publicApi
905852
*/
906853
export interface HostListener {
907854
/**

packages/core/src/metadata/ng_module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ export interface NgModuleDecorator {
127127

128128
/**
129129
* Type of the NgModule metadata.
130+
*
131+
* @publicApi
130132
*/
131133
export interface NgModule {
132134
/**

packages/core/testing/src/test_bed.ts

+3-12
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const UNDEFINED = new Object();
2020

2121
let _nextRootElementId = 0;
2222

23+
/**
24+
* @publicApi
25+
*/
2326
export interface TestBed {
2427
platform: PlatformRef;
2528

@@ -35,16 +38,12 @@ export interface TestBed {
3538
*
3639
* Test modules and platforms for individual platforms are available from
3740
* '@angular/<platform_name>/testing'.
38-
*
39-
* @publicApi
4041
*/
4142
initTestEnvironment(
4243
ngModule: Type<any>|Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): void;
4344

4445
/**
4546
* Reset the providers for the test injector.
46-
*
47-
* @publicApi
4847
*/
4948
resetTestEnvironment(): void;
5049

@@ -119,8 +118,6 @@ export class TestBedViewEngine implements Injector, TestBed {
119118
*
120119
* Test modules and platforms for individual platforms are available from
121120
* '@angular/<platform_name>/testing'.
122-
*
123-
* @publicApi
124121
*/
125122
static initTestEnvironment(
126123
ngModule: Type<any>|Type<any>[], platform: PlatformRef,
@@ -132,8 +129,6 @@ export class TestBedViewEngine implements Injector, TestBed {
132129

133130
/**
134131
* Reset the providers for the test injector.
135-
*
136-
* @publicApi
137132
*/
138133
static resetTestEnvironment(): void { _getTestBedViewEngine().resetTestEnvironment(); }
139134

@@ -291,8 +286,6 @@ export class TestBedViewEngine implements Injector, TestBed {
291286
*
292287
* Test modules and platforms for individual platforms are available from
293288
* '@angular/<platform_name>/testing'.
294-
*
295-
* @publicApi
296289
*/
297290
initTestEnvironment(
298291
ngModule: Type<any>|Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): void {
@@ -308,8 +301,6 @@ export class TestBedViewEngine implements Injector, TestBed {
308301

309302
/**
310303
* Reset the providers for the test injector.
311-
*
312-
* @publicApi
313304
*/
314305
resetTestEnvironment(): void {
315306
this.resetTestingModule();

0 commit comments

Comments
 (0)