Skip to content

Commit dfc3176

Browse files
ftr93kroeder
authored andcommitted
docs: add example for extended interface type extraction
1 parent f5d544a commit dfc3176

File tree

5 files changed

+60
-1
lines changed

5 files changed

+60
-1
lines changed

packages/angular-demo/src/app/app.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, Input } from '@angular/core';
22
import { ChildComponent } from './child.component';
33
import { getLibraryAuthor } from './other-utils';
4-
import { getProductNumber, Product, UndocumentedSecret } from './types';
4+
import { RaceCar, getProductNumber, Product, UndocumentedSecret } from './types';
55
import { ENVIRONMENT, IS_STANDALONE, isNumber, isString, LIB_NAME, VERSION } from './utils';
66

77
@Component({
@@ -28,6 +28,14 @@ export class AppComponent {
2828
hiddenProperty: '',
2929
};
3030

31+
raceCar: RaceCar = {
32+
brand: 'Ferrari',
33+
model: '812 Superfast',
34+
maxSpeed: 320,
35+
price: 1500000,
36+
numberOfWheels: 4,
37+
};
38+
3139
/**
3240
* @exclude-docs
3341
*/

packages/angular-demo/src/app/stories/interface.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ export interface Price {
5656

5757
<ArgTypes of="Charge" />
5858

59+
### RaceCar
60+
61+
<ArgTypes of="RaceCar" />
62+
5963
## Without @include-docs
6064

6165
Interfaces without the `@include-docs` annotation are ignored.

packages/angular-demo/src/app/types.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { PricedItem } from '@scope/entrypoint'; // eslint-disable-line @nx/enforce-module-boundaries
2+
13
export interface UndocumentedSecret {
24
secret: string;
35
}
@@ -71,3 +73,38 @@ export interface Price {
7173
export function getProductNumber(product: Product) {
7274
return `${product.id}X${product.itemNumber}`;
7375
}
76+
77+
/**
78+
* @include-docs
79+
*/
80+
export interface RaceCar extends Car, Vehicle, PricedItem {
81+
/**
82+
* Maximum speed in km/h.
83+
*/
84+
maxSpeed: number;
85+
}
86+
87+
export interface Car {
88+
/**
89+
* Model name
90+
*
91+
* This is a property from an extended interface.
92+
*/
93+
model: string;
94+
95+
/**
96+
* Brand name
97+
*
98+
* This is a property from an extended interface.
99+
*/
100+
brand: string;
101+
}
102+
103+
export interface Vehicle {
104+
/**
105+
* Number of wheels
106+
*
107+
* This is a property from another extended interface.
108+
*/
109+
numberOfWheels: number;
110+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { GreatGrandParentDirective } from './great-grand-parent.directive';
2+
export { PricedItem } from './types';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export interface PricedItem {
2+
/**
3+
* Price of the product
4+
*
5+
* This is a property from an extended interface imported from a
6+
* secondary entry point.
7+
*/
8+
price: number;
9+
}

0 commit comments

Comments
 (0)