mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 14:05:47 -05:00
Verify demo build
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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",
|
||||
|
||||
80
src/testRunner/unittests/tsbuild/demo.ts
Normal file
80
src/testRunner/unittests/tsbuild/demo.ts
Normal 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
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -25,8 +25,8 @@ class someClass { }
|
||||
"program": {
|
||||
"fileInfos": {
|
||||
"../../lib/lib.d.ts": {
|
||||
"version": "-15964756381",
|
||||
"signature": "-15964756381"
|
||||
"version": "3858781397",
|
||||
"signature": "3858781397"
|
||||
},
|
||||
"./anothermodule.ts": {
|
||||
"version": "-2676574883",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
4
tests/projects/demo/animals/animal.ts
Normal file
4
tests/projects/demo/animals/animal.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export type Size = "small" | "medium" | "large";
|
||||
export default interface Animal {
|
||||
size: Size;
|
||||
}
|
||||
18
tests/projects/demo/animals/dog.ts
Normal file
18
tests/projects/demo/animals/dog.ts
Normal 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()
|
||||
});
|
||||
}
|
||||
|
||||
5
tests/projects/demo/animals/index.ts
Normal file
5
tests/projects/demo/animals/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import Animal from './animal';
|
||||
|
||||
export default Animal;
|
||||
import { createDog, Dog } from './dog';
|
||||
export { createDog, Dog };
|
||||
10
tests/projects/demo/animals/tsconfig.json
Normal file
10
tests/projects/demo/animals/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../tsconfig-base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../lib/animals",
|
||||
"rootDir": ".",
|
||||
},
|
||||
"references": [
|
||||
{ "path": "../core" }
|
||||
]
|
||||
}
|
||||
7
tests/projects/demo/core/tsconfig.json
Normal file
7
tests/projects/demo/core/tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../tsconfig-base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../lib/core",
|
||||
"rootDir": "."
|
||||
}
|
||||
}
|
||||
10
tests/projects/demo/core/utilities.ts
Normal file
10
tests/projects/demo/core/utilities.ts
Normal 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];
|
||||
}
|
||||
|
||||
13
tests/projects/demo/tsconfig-base.json
Normal file
13
tests/projects/demo/tsconfig-base.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"composite": true
|
||||
}
|
||||
}
|
||||
14
tests/projects/demo/tsconfig.json
Normal file
14
tests/projects/demo/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./core"
|
||||
},
|
||||
{
|
||||
"path": "./animals"
|
||||
},
|
||||
{
|
||||
"path": "./zoo"
|
||||
}
|
||||
]
|
||||
}
|
||||
12
tests/projects/demo/zoo/tsconfig.json
Normal file
12
tests/projects/demo/zoo/tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "../tsconfig-base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../lib/zoo",
|
||||
"rootDir": "."
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "../animals"
|
||||
}
|
||||
]
|
||||
}
|
||||
9
tests/projects/demo/zoo/zoo.ts
Normal file
9
tests/projects/demo/zoo/zoo.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
// import Animal from '../animals/index';
|
||||
import { Dog, createDog } from '../animals/index';
|
||||
|
||||
export function createZoo(): Array<Dog> {
|
||||
return [
|
||||
createDog()
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user