Skip to content

Commit 5200f44

Browse files
committed
Add a new unit test for the definition trimming feature
1 parent bbe7eb5 commit 5200f44

File tree

14 files changed

+249
-5
lines changed

14 files changed

+249
-5
lines changed

build-tests/api-extractor-test-01/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
// See LICENSE in the project root for license information.
33

44
/**
5-
* Example documentation for the package.
5+
* api-extractor-test-01
66
*
77
* @remarks
8-
* Additional remarks
8+
* This library is consumed by api-extractor-test-02 and api-extractor-test-03.
9+
* It tests the basic types of definitions, and all the weird cases for following
10+
* chains of type aliases.
911
*
1012
* @packagedocumentation
1113
*/

build-tests/api-extractor-test-02/src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
// See LICENSE in the project root for license information.
33

44
/**
5-
* Example documentation for the package.
5+
* api-extractor-test-02
66
*
77
* @remarks
8-
* Additional remarks
8+
* This library consumes api-extractor-test-01 and is consumed by api-extractor-test-03.
99
*
1010
* @packagedocumentation
1111
*/
12-
1312
export { SubclassWithImport } from './SubclassWithImport';
1413

1514
export * from './TypeFromImportedModule';

build-tests/api-extractor-test-03/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4+
/**
5+
* api-extractor-test-03
6+
*
7+
* Test scenarios for consuming a library (api-extractor-test-02) that consumes
8+
* an indirect dependency (api-extractor-test-01).
9+
*/
10+
411
import { SubclassWithImport } from 'api-extractor-test-02';
512

613
const subclassWithImport: SubclassWithImport = new SubclassWithImport();
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://dev.office.com/json-schemas/api-extractor/api-extractor.schema.json",
3+
"compiler" : {
4+
"configType": "tsconfig",
5+
"rootFolder": "."
6+
},
7+
8+
"packageTypings": {
9+
"enabled": true
10+
},
11+
12+
"project": {
13+
"entryPointSourceFile": "lib/index.d.ts"
14+
}
15+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fsx = require('fs-extra');
2+
const child_process = require('child_process');
3+
const path = require('path');
4+
const process = require('process');
5+
6+
function executeCommand(command) {
7+
console.log('---> ' + command);
8+
child_process.execSync(command, { stdio: 'inherit' });
9+
}
10+
11+
// Clean the old build outputs
12+
console.log(`==> Starting build.js for ${path.basename(process.cwd())}`);
13+
fsx.emptyDirSync('dist');
14+
fsx.emptyDirSync('lib');
15+
fsx.emptyDirSync('temp');
16+
17+
// Run the TypeScript compiler
18+
executeCommand('node node_modules/typescript/lib/tsc');
19+
20+
// Run the API Extractor command-line
21+
if (process.argv.indexOf('--production') >= 0) {
22+
executeCommand('node node_modules/@microsoft/api-extractor/lib/start run');
23+
} else {
24+
executeCommand('node node_modules/@microsoft/api-extractor/lib/start run --local');
25+
}
26+
27+
console.log(`==> Finished build.js for ${path.basename(process.cwd())}`);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// @alpha
2+
class AlphaClass {
3+
// @internal
4+
_internalMember(): void;
5+
undecoratedMember(): void;
6+
}
7+
8+
// @beta
9+
class BetaClass {
10+
// @internal
11+
_internalMember(): void;
12+
// @alpha
13+
alphaMember(): void;
14+
undecoratedMember(): void;
15+
}
16+
17+
// WARNING: Because this definition is explicitly marked as @internal, an underscore prefix ("_") should be added to its name
18+
// @internal
19+
class InternalClass {
20+
undecoratedMember(): void;
21+
}
22+
23+
// @public
24+
class PublicClass {
25+
// @internal
26+
_internalMember(): void;
27+
// @alpha
28+
alphaMember(): void;
29+
// @beta
30+
betaMember(): void;
31+
undecoratedMember(): void;
32+
}
33+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "api-extractor-test-04",
3+
"description": "Building this project is a regression test for api-extractor",
4+
"version": "1.0.0",
5+
"private": true,
6+
"main": "lib/index.js",
7+
"typings": "dist/index-internal.d.ts",
8+
"scripts": {
9+
"build": "node build.js"
10+
},
11+
"dependencies": {
12+
"@microsoft/api-extractor": "5.3.5",
13+
"fs-extra": "~0.26.7",
14+
"typescript": "~2.4.1"
15+
}
16+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
4+
/**
5+
* This is an alpha class.
6+
* @alpha
7+
*/
8+
export class AlphaClass {
9+
/**
10+
* This is a comment
11+
*/
12+
public undecoratedMember(): void {
13+
}
14+
15+
/**
16+
* This is an internal member
17+
* @internal
18+
*/
19+
public _internalMember(): void {
20+
}
21+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
4+
/**
5+
* This is a beta class
6+
* @beta
7+
*/
8+
export class BetaClass {
9+
/**
10+
* This is a comment
11+
*/
12+
public undecoratedMember(): void {
13+
}
14+
15+
/**
16+
* This is an alpha comment
17+
* @alpha
18+
*/
19+
public alphaMember(): void {
20+
}
21+
22+
/**
23+
* This is an internal member
24+
* @internal
25+
*/
26+
public _internalMember(): void {
27+
}
28+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
4+
/**
5+
* This is an internal class
6+
* @internal
7+
*/
8+
export class InternalClass {
9+
/**
10+
* This is a comment
11+
*/
12+
public undecoratedMember(): void {
13+
}
14+
}

0 commit comments

Comments
 (0)