Skip to content

Commit e94da6e

Browse files
committed
Adding a regression test project "api-extractor-test-01" that builds using a trivial build.js script
1 parent dbb42ea commit e94da6e

File tree

9 files changed

+201
-0
lines changed

9 files changed

+201
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"$schema": "https://dev.office.com/json-schemas/api-extractor/api-extractor.schema.json",
3+
"compiler" : {
4+
"configType": "tsconfig",
5+
"rootFolder": ".",
6+
7+
"overrideTsconfig": {
8+
"compilerOptions": {
9+
"target": "es6",
10+
"forceConsistentCasingInFileNames": true,
11+
"module": "commonjs",
12+
"declaration": true,
13+
"sourceMap": true,
14+
"experimentalDecorators": true,
15+
"strictNullChecks": true,
16+
"types": [
17+
"node",
18+
"jest"
19+
],
20+
"lib": [
21+
"es5",
22+
"scripthost",
23+
"es2015.collection",
24+
"es2015.promise",
25+
"es2015.iterable",
26+
"dom"
27+
]
28+
},
29+
"include": [
30+
// TODO: Automatically generate this from the real tsconfig.json
31+
"lib/index.d.ts",
32+
"typings/tsd.d.ts"
33+
]
34+
}
35+
36+
},
37+
38+
"apiJsonFile": {
39+
"enabled": true
40+
},
41+
42+
"apiReviewFile": {
43+
"enabled": true
44+
},
45+
46+
"project": {
47+
"entryPointSourceFile": "lib/index.d.ts"
48+
}
49+
}
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "api-extractor-test-01",
3+
"description": "Building this project is a regression test for api-extractor",
4+
"version": "1.0.0",
5+
"main": "lib/index.js",
6+
"typings": "lib/index.d.ts",
7+
"scripts": {
8+
"build": "node build.js"
9+
},
10+
"dependencies": {
11+
"@microsoft/api-extractor": "4.3.4",
12+
"@types/jest": "~20.0.4",
13+
"@types/node": "6.0.88",
14+
"fs-extra": "~0.26.7",
15+
"typescript": "~2.4.1"
16+
}
17+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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 class gets aliased twice before being exported from the package.
6+
*/
7+
export { ReexportedClass2 as ReexportedClass1 } from './ReexportedClass2';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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 class gets aliased twice before being exported from the package.
6+
* @public
7+
*/
8+
export class ReexportedClass2 {
9+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
* Example package docs.
6+
*/
7+
declare const packageDescription: void; // tslint:disable-line:no-unused-variable
8+
9+
/**
10+
* Test the alias-following logic: This class gets aliased twice before being
11+
* exported from the package.
12+
*/
13+
export { ReexportedClass1 as ReexportedClass } from './ReexportedClass1';
14+
15+
/**
16+
* A simple, normal definition
17+
* @public
18+
*/
19+
export interface ISimpleInterface {
20+
}
21+
22+
/**
23+
* Test different kinds of ambient definitions
24+
* @public
25+
*/
26+
export class AmbientConsumer {
27+
// Found via tsconfig.json's "lib" setting, which specifies the built-in "es2015.collection"
28+
public builtinDefinition1(): Map<string, string> {
29+
return new Map<string, string>();
30+
}
31+
32+
// Found via tsconfig.json's "lib" setting, which specifies the built-in "es2015.promise"
33+
public builtinDefinition2(): Promise<void> {
34+
return new Promise<void>(() => { /* */ });
35+
}
36+
37+
// Configured via tsconfig.json's "lib" setting, which specifies "@types/jest".
38+
// The emitted index.d.ts gets a reference like this: <reference types="jest" />
39+
public definitelyTyped(): jest.Context {
40+
return {} as jest.Context;
41+
}
42+
43+
// Found via tsconfig.json's "include" setting point to a *.d.ts file.
44+
// This is an old-style Definitely Typed definition, which is the worst possible kind,
45+
// because consumers are expected to provide this, with no idea where it came from.
46+
public localTypings(): IAmbientInterfaceExample {
47+
return {} as IAmbientInterfaceExample;
48+
}
49+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es6",
4+
"forceConsistentCasingInFileNames": true,
5+
"module": "commonjs",
6+
"declaration": true,
7+
"sourceMap": true,
8+
"experimentalDecorators": true,
9+
"strictNullChecks": true,
10+
"types": [
11+
"node",
12+
"jest"
13+
],
14+
"lib": [
15+
"es5",
16+
"scripthost",
17+
"es2015.collection",
18+
"es2015.promise",
19+
"es2015.iterable",
20+
"dom"
21+
],
22+
"outDir": "lib"
23+
},
24+
"include": [
25+
"src/**/*.ts",
26+
"typings/tsd.d.ts"
27+
]
28+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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+
// Simulate legacy-style Definitely Typed typings
5+
interface IAmbientInterfaceExample {
6+
member: number;
7+
}

rush.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@
5858
"shouldPublish": false
5959
},
6060

61+
// "build-tests" folder (alphabetical order)
62+
{
63+
"packageName": "api-extractor-test-01",
64+
"projectFolder": "build-tests/api-extractor-test-01",
65+
"reviewCategory": "libraries",
66+
"shouldPublish": false
67+
},
68+
6169
// "core-build" folder (alphabetical order)
6270
{
6371
"packageName": "@microsoft/gulp-core-build",

0 commit comments

Comments
 (0)