Verify demo build

This commit is contained in:
Sheetal Nandi
2019-08-07 12:36:27 -07:00
parent 85b8d27ea3
commit d9ad559042
31 changed files with 243 additions and 60 deletions

View File

@@ -11,7 +11,7 @@ interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> {}`
interface Array<T> { length: number; [n: number]: T; }`
};
export const safeList = {

View File

@@ -93,6 +93,7 @@
"unittests/services/transpile.ts",
"unittests/tsbuild/amdModulesWithOut.ts",
"unittests/tsbuild/containerOnlyReferenced.ts",
"unittests/tsbuild/demo.ts",
"unittests/tsbuild/emptyFiles.ts",
"unittests/tsbuild/graphOrdering.ts",
"unittests/tsbuild/inferredTypeFromTransitiveModule.ts",

View File

@@ -0,0 +1,80 @@
namespace ts {
describe("unittests:: tsbuild:: on demo project", () => {
let projFs: vfs.FileSystem;
const { time } = getTime();
before(() => {
projFs = loadProjectFromDisk("tests/projects/demo", time);
});
after(() => {
projFs = undefined!; // Release the contents
});
function coreOutputs(): string[] {
return [
"/src/lib/core/utilities.js",
"/src/lib/core/utilities.d.ts",
"/src/lib/core/tsconfig.tsbuildinfo"
];
}
function animalOutputs(): string[] {
return [
"/src/lib/animals/animal.js",
"/src/lib/animals/animal.d.ts",
"/src/lib/animals/index.js",
"/src/lib/animals/index.d.ts",
"/src/lib/animals/dog.js",
"/src/lib/animals/dog.d.ts",
"/src/lib/animals/tsconfig.tsbuildinfo"
];
}
function zooOutputs(): string[] {
return [
"/src/lib/zoo/zoo.js",
"/src/lib/zoo/zoo.d.ts",
"/src/lib/zoo/tsconfig.tsbuildinfo"
];
}
interface VerifyBuild {
modifyDiskLayout: (fs: vfs.FileSystem) => void;
expectedExitStatus: ExitStatus;
expectedDiagnostics: fakes.ExpectedDiagnostic[];
expectedOutputs: readonly string[];
notExpectedOutputs: readonly string[];
}
function verifyBuild({ modifyDiskLayout, expectedExitStatus, expectedDiagnostics, expectedOutputs, notExpectedOutputs }: VerifyBuild) {
const fs = projFs.shadow();
const host = new fakes.SolutionBuilderHost(fs);
modifyDiskLayout(fs);
const builder = createSolutionBuilder(host, ["/src/tsconfig.json"], { verbose: true });
const exitStatus = builder.build();
assert.equal(exitStatus, expectedExitStatus);
host.assertDiagnosticMessages(...expectedDiagnostics);
verifyOutputsPresent(fs, expectedOutputs);
verifyOutputsAbsent(fs, notExpectedOutputs);
}
it("in master branch with everything setup correctly, reports no error", () => {
verifyBuild({
modifyDiskLayout: noop,
expectedExitStatus: ExitStatus.Success,
expectedDiagnostics: [
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/animals/tsconfig.json", "src/zoo/tsconfig.json", "src/tsconfig.json"),
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/lib/core/utilities.js"],
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"],
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/animals/tsconfig.json", "src/lib/animals/animal.js"],
[Diagnostics.Building_project_0, "/src/animals/tsconfig.json"],
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/zoo/tsconfig.json", "src/lib/zoo/zoo.js"],
[Diagnostics.Building_project_0, "/src/zoo/tsconfig.json"]
],
expectedOutputs: [...coreOutputs(), ...animalOutputs(), ...zooOutputs()],
notExpectedOutputs: emptyArray
});
});
});
}

View File

@@ -31,8 +31,8 @@ export declare const lazyBar: LazyAction<() => void, typeof import("./lazyIndex"
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../bar.ts": {
"version": "747071916",

View File

@@ -69,8 +69,8 @@ exports.bar = bar_1.default;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../bar.ts": {
"version": "5936740878",

View File

@@ -22,8 +22,8 @@ type A = HKT<number>[typeof sym];
"program": {
"fileInfos": {
"../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"./src/globals.d.ts": {
"version": "-1994196675",

View File

@@ -15,8 +15,8 @@ var x = 10;
"program": {
"fileInfos": {
"../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"./src/globals.d.ts": {
"version": "-1994196675",

View File

@@ -172,8 +172,8 @@ export class someClass { }
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"./anothermodule.ts": {
"version": "-2676574883",
@@ -212,8 +212,8 @@ export class someClass { }
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../core/index.ts": {
"version": "-2069755619",
@@ -262,8 +262,8 @@ export class someClass { }
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../core/index.ts": {
"version": "-2069755619",

View File

@@ -21,8 +21,8 @@ export declare function multiply(a: number, b: number): number;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"./anothermodule.ts": {
"version": "-2676574883",

View File

@@ -37,8 +37,8 @@ exports.m = mod;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../core/index.ts": {
"version": "-13851440507",

View File

@@ -25,8 +25,8 @@ export declare const m: typeof mod;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../core/index.ts": {
"version": "-13851440507",
@@ -76,8 +76,8 @@ export declare const m: typeof mod;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../core/index.ts": {
"version": "-13851440507",

View File

@@ -31,8 +31,8 @@ define(["require", "exports"], function (require, exports) {
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"./anothermodule.ts": {
"version": "-2676574883",

View File

@@ -33,8 +33,8 @@ exports.multiply = multiply;
"signature": "8926001564"
},
"../../lib/lib.esnext.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"./anothermodule.ts": {
"version": "-2676574883",

View File

@@ -25,8 +25,8 @@ class someClass { }
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"./anothermodule.ts": {
"version": "-2676574883",

View File

@@ -185,8 +185,8 @@ exports.multiply = multiply;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"./anothermodule.ts": {
"version": "-2676574883",
@@ -370,8 +370,8 @@ sourceFile:index.ts
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../core/index.ts": {
"version": "-13851440507",
@@ -436,8 +436,8 @@ exports.m = mod;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../core/index.ts": {
"version": "-13851440507",

View File

@@ -27,8 +27,8 @@ exports.multiply = multiply;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"./anothermodule.ts": {
"version": "-2676574883",

View File

@@ -35,8 +35,8 @@ exports.multiply = multiply;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"./anothermodule.ts": {
"version": "-2676574883",
@@ -96,8 +96,8 @@ exports.m = mod;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../core/index.ts": {
"version": "-13851440507",
@@ -178,8 +178,8 @@ exports.m = mod;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../core/index.ts": {
"version": "-13851440507",

View File

@@ -185,8 +185,8 @@ exports.multiply = multiply;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"./anothermodule.ts": {
"version": "-2676574883",
@@ -370,8 +370,8 @@ sourceFile:index.ts
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../core/index.ts": {
"version": "-13851440507",
@@ -436,8 +436,8 @@ exports.m = mod;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../core/index.ts": {
"version": "-13851440507",

View File

@@ -185,8 +185,8 @@ exports.multiply = multiply;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"./anothermodule.ts": {
"version": "-2676574883",
@@ -370,8 +370,8 @@ sourceFile:index.ts
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../core/index.ts": {
"version": "-13851440507",
@@ -453,8 +453,8 @@ exports.m = mod;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../core/index.ts": {
"version": "-13851440507",

View File

@@ -27,8 +27,8 @@ exports.multiply = multiply;
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"./anothermodule.ts": {
"version": "-2676574883",

View File

@@ -13,7 +13,7 @@ interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> {}
interface Array<T> { length: number; [n: number]: T; }
interface ReadonlyArray<T> {}
declare const console: { log(msg: any): void; };
@@ -46,8 +46,8 @@ export function multiply(a, b) { return a * b; }
"program": {
"fileInfos": {
"../../lib/lib.esnext.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
"version": "3858781397",
"signature": "3858781397"
},
"../../lib/lib.esnext.full.d.ts": {
"version": "8926001564",

View File

@@ -0,0 +1,4 @@
export type Size = "small" | "medium" | "large";
export default interface Animal {
size: Size;
}

View File

@@ -0,0 +1,18 @@
import Animal from '.';
import { makeRandomName } from '../core/utilities';
export interface Dog extends Animal {
woof(): void;
name: string;
}
export function createDog(): Dog {
return ({
size: "medium",
woof: function(this: Dog) {
console.log(`${this.name} says "Woof"!`);
},
name: makeRandomName()
});
}

View File

@@ -0,0 +1,5 @@
import Animal from './animal';
export default Animal;
import { createDog, Dog } from './dog';
export { createDog, Dog };

View File

@@ -0,0 +1,10 @@
{
"extends": "../tsconfig-base.json",
"compilerOptions": {
"outDir": "../lib/animals",
"rootDir": ".",
},
"references": [
{ "path": "../core" }
]
}

View File

@@ -0,0 +1,7 @@
{
"extends": "../tsconfig-base.json",
"compilerOptions": {
"outDir": "../lib/core",
"rootDir": "."
}
}

View File

@@ -0,0 +1,10 @@
export function makeRandomName() {
return "Bob!?! ";
}
export function lastElementOf<T>(arr: T[]): T | undefined {
if (arr.length === 0) return undefined;
return arr[arr.length - 1];
}

View File

@@ -0,0 +1,13 @@
{
"compilerOptions": {
"declaration": true,
"target": "es5",
"module": "commonjs",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"composite": true
}
}

View File

@@ -0,0 +1,14 @@
{
"files": [],
"references": [
{
"path": "./core"
},
{
"path": "./animals"
},
{
"path": "./zoo"
}
]
}

View File

@@ -0,0 +1,12 @@
{
"extends": "../tsconfig-base.json",
"compilerOptions": {
"outDir": "../lib/zoo",
"rootDir": "."
},
"references": [
{
"path": "../animals"
}
]
}

View File

@@ -0,0 +1,9 @@
// import Animal from '../animals/index';
import { Dog, createDog } from '../animals/index';
export function createZoo(): Array<Dog> {
return [
createDog()
];
}