mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Tests refactor for easy comparison between outFile and multiFile scenario (#58761)
This commit is contained in:
@@ -78,7 +78,7 @@ export function forEachDeclarationEmitWithErrorsScenario(
|
||||
for (const outFile of [false, true]) {
|
||||
for (const incremental of [undefined, true] as const) {
|
||||
action(
|
||||
scenario => `${scenario}${outFile ? " outFile" : ""}${incremental ? " with incremental" : ""}`,
|
||||
scenario => `${outFile ? "outFile" : "multiFile"}/${scenario}${incremental ? " with incremental" : ""}`,
|
||||
() =>
|
||||
(outFile ? getFsForDeclarationEmitWithErrorsWithOutFile :
|
||||
getFsForDeclarationEmitWithErrors)(
|
||||
|
||||
@@ -46,7 +46,7 @@ export function forEachNoEmitOnErrorScenario<T>(
|
||||
for (const declaration of [undefined, true] as const) {
|
||||
for (const incremental of [undefined, true] as const) {
|
||||
action(
|
||||
scenario => `${scenario}${outFile ? " outFile" : ""}${declaration ? " with declaration" : ""}${incremental ? " with incremental" : ""}`,
|
||||
scenario => `${outFile ? "outFile" : "multiFile"}/${scenario}${declaration ? " with declaration" : ""}${incremental ? " with incremental" : ""}`,
|
||||
() =>
|
||||
loadFs(
|
||||
getFsContentsForNoEmitOnError(outFile, declaration, incremental),
|
||||
|
||||
@@ -13,6 +13,9 @@ import {
|
||||
} from "../helpers/vfs.js";
|
||||
|
||||
describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
function scenarioName(text: string, options: ts.CompilerOptions) {
|
||||
return `${options.outFile ? "outFile" : "multiFile"}/${text}`;
|
||||
}
|
||||
describe("different options::", () => {
|
||||
function withOptionChange(caption: string, ...options: readonly string[]): TestTscEdit {
|
||||
return {
|
||||
@@ -77,92 +80,53 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
"/src/project/d.ts": `import { b } from "./b";export const d = b;`,
|
||||
});
|
||||
}
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "different options",
|
||||
fs: () => fs({ composite: true }),
|
||||
commandLineArgs: ["--b", "/src/project", "--verbose"],
|
||||
edits: [
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("should re-emit only js so they dont contain sourcemap"),
|
||||
withOptionChangeAndDiscrepancyExplanation("with declaration should not emit anything", "--declaration"),
|
||||
noChangeRun,
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
noChangeWithSubscenario("should re-emit only dts so they dont contain sourcemap"),
|
||||
withOptionChangeAndDiscrepancyExplanation("with emitDeclarationOnly should not emit anything", "--emitDeclarationOnly"),
|
||||
noChangeRun,
|
||||
localChange(),
|
||||
withOptionChangeAndDiscrepancyExplanation("with declaration should not emit anything", "--declaration"),
|
||||
withOptionChange("with inlineSourceMap", "--inlineSourceMap"),
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "different options with outFile",
|
||||
fs: () => fs({ composite: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD }),
|
||||
commandLineArgs: ["--b", "/src/project", "--verbose"],
|
||||
edits: [
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("should re-emit only js so they dont contain sourcemap"),
|
||||
withOptionChangeAndDiscrepancyExplanation("with declaration should not emit anything", "--declaration"),
|
||||
noChangeRun,
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
noChangeWithSubscenario("should re-emit only dts so they dont contain sourcemap"),
|
||||
withEmitDeclarationOnlyChangeAndDiscrepancyExplanation("with emitDeclarationOnly should not emit anything"),
|
||||
noChangeRun,
|
||||
localChange(),
|
||||
withOptionChangeAndDiscrepancyExplanation("with declaration should not emit anything", "--declaration"),
|
||||
withOptionChange("with inlineSourceMap", "--inlineSourceMap"),
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "different options with incremental",
|
||||
fs: () => fs({ incremental: true }),
|
||||
commandLineArgs: ["--b", "/src/project", "--verbose"],
|
||||
edits: [
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
withOptionChange("should re-emit only js so they dont contain sourcemap"),
|
||||
withOptionChange("with declaration, emit Dts and should not emit js", "--declaration"),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
nochangeWithIncrementalDeclarationFromBeforeExplaination(),
|
||||
localChange(),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
nochangeWithIncrementalDeclarationFromBeforeExplaination(),
|
||||
withOptionChange("with inlineSourceMap", "--inlineSourceMap"),
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("emit js files"),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
withOptionChange("with declaration and declarationMap, should not re-emit", "--declaration", "--declarationMap"),
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "different options with incremental with outFile",
|
||||
fs: () => fs({ incremental: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD }),
|
||||
commandLineArgs: ["--b", "/src/project", "--verbose"],
|
||||
edits: [
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("should re-emit only js so they dont contain sourcemap"),
|
||||
withOptionChange("with declaration, emit Dts and should not emit js", "--declaration"),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
nochangeWithIncrementalOutDeclarationFromBeforeExplaination(),
|
||||
localChange(),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
nochangeWithIncrementalOutDeclarationFromBeforeExplaination(),
|
||||
withOptionChange("with inlineSourceMap", "--inlineSourceMap"),
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("emit js files"),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
withOptionChange("with declaration and declarationMap, should not re-emit", "--declaration", "--declarationMap"),
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
function verify(options: ts.CompilerOptions) {
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: scenarioName("different options", options),
|
||||
fs: () => fs({ composite: true, ...options }),
|
||||
commandLineArgs: ["--b", "/src/project", "--verbose"],
|
||||
edits: [
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("should re-emit only js so they dont contain sourcemap"),
|
||||
withOptionChangeAndDiscrepancyExplanation("with declaration should not emit anything", "--declaration"),
|
||||
noChangeRun,
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
noChangeWithSubscenario("should re-emit only dts so they dont contain sourcemap"),
|
||||
withOptionChangeAndDiscrepancyExplanation("with emitDeclarationOnly should not emit anything", "--emitDeclarationOnly"),
|
||||
noChangeRun,
|
||||
localChange(),
|
||||
!options.outFile ? withOptionChangeAndDiscrepancyExplanation("with declaration should not emit anything", "--declaration") : withEmitDeclarationOnlyChangeAndDiscrepancyExplanation("with emitDeclarationOnly should not emit anything"),
|
||||
withOptionChange("with inlineSourceMap", "--inlineSourceMap"),
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: scenarioName("different options with incremental", options),
|
||||
fs: () => fs({ incremental: true, ...options }),
|
||||
commandLineArgs: ["--b", "/src/project", "--verbose"],
|
||||
edits: [
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
withOptionChange("should re-emit only js so they dont contain sourcemap"),
|
||||
withOptionChange("with declaration, emit Dts and should not emit js", "--declaration"),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
!options.outFile ? nochangeWithIncrementalDeclarationFromBeforeExplaination() : nochangeWithIncrementalOutDeclarationFromBeforeExplaination(),
|
||||
localChange(),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
!options.outFile ? nochangeWithIncrementalDeclarationFromBeforeExplaination() : nochangeWithIncrementalOutDeclarationFromBeforeExplaination(),
|
||||
withOptionChange("with inlineSourceMap", "--inlineSourceMap"),
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("emit js files"),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
withOptionChange("with declaration and declarationMap, should not re-emit", "--declaration", "--declarationMap"),
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
}
|
||||
verify({});
|
||||
verify({ outFile: "../outFile.js", module: ts.ModuleKind.AMD });
|
||||
});
|
||||
describe("emitDeclarationOnly::", () => {
|
||||
function fs(options: ts.CompilerOptions) {
|
||||
@@ -274,7 +238,7 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
baselinePrograms: true,
|
||||
});
|
||||
function subScenario(text: string) {
|
||||
return `${text}${options.composite ? "" : " with declaration and incremental"}${options.outFile ? " with outFile" : ""}`;
|
||||
return scenarioName(`${text}${options.composite ? "" : " with declaration and incremental"}`, options);
|
||||
}
|
||||
}
|
||||
verifyWithIncremental({ composite: true });
|
||||
@@ -282,152 +246,82 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
verifyWithIncremental({ composite: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD });
|
||||
verifyWithIncremental({ incremental: true, declaration: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD });
|
||||
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "emitDeclarationOnly on commandline with declaration",
|
||||
fs: () => fs({ declaration: true }),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly"],
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "non local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "export const aaa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "emit js files",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "js emit with change without emitDeclarationOnly",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const alocal = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
{
|
||||
caption: "local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const aaaa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "non local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "export const aaaaa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "js emit with change without emitDeclarationOnly",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "export const a2 = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
function verifyNonIncremental(options: ts.CompilerOptions) {
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: scenarioName("emitDeclarationOnly on commandline with declaration", options),
|
||||
fs: () => fs({ declaration: true, ...options }),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly"],
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "non local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "export const aaa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "emit js files",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "js emit with change without emitDeclarationOnly",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const alocal = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
{
|
||||
caption: "local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const aaaa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "non local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "export const aaaaa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "js emit with change without emitDeclarationOnly",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "export const a2 = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "emitDeclarationOnly false on commandline with declaration",
|
||||
fs: () => fs({ declaration: true, emitDeclarationOnly: true }),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "emit js files",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "no change run with js emit",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
{
|
||||
caption: "js emit with change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const blocal = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "emitDeclarationOnly on commandline with declaration with outFile",
|
||||
fs: () => fs({ declaration: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD }),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly"],
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "non local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "export const aaa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "emit js files",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "js emit with change without emitDeclarationOnly",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const alocal = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
{
|
||||
caption: "local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const aaaa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "non local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "export const aaaaa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "js emit with change without emitDeclarationOnly",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "export const a2 = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "emitDeclarationOnly false on commandline with declaration with outFile",
|
||||
fs: () => fs({ declaration: true, emitDeclarationOnly: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD }),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "emit js files",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "no change run with js emit",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
{
|
||||
caption: "js emit with change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const blocal = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: scenarioName("emitDeclarationOnly false on commandline with declaration", options),
|
||||
fs: () => fs({ declaration: true, emitDeclarationOnly: true, ...options }),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
},
|
||||
{
|
||||
caption: "emit js files",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "no change run with js emit",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
{
|
||||
caption: "js emit with change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const blocal = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
}
|
||||
verifyNonIncremental({});
|
||||
verifyNonIncremental({ outFile: "../outFile.js", module: ts.ModuleKind.AMD });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@ describe("unittests:: tsbuild:: configFileErrors:: reports syntax errors in conf
|
||||
function verify(outFile?: object) {
|
||||
verifyTsc({
|
||||
scenario: "configFileErrors",
|
||||
subScenario: `reports syntax errors in config file${outFile ? " with outFile" : ""}`,
|
||||
subScenario: `${outFile ? "outFile" : "multiFile"}/reports syntax errors in config file`,
|
||||
fs: () =>
|
||||
loadProjectFromFiles({
|
||||
"/src/a.ts": "export function foo() { }",
|
||||
|
||||
@@ -38,7 +38,7 @@ describe("unittests:: tsbuild:: fileDelete::", () => {
|
||||
|
||||
verifyTsc({
|
||||
scenario: "fileDelete",
|
||||
subScenario: `detects deleted file`,
|
||||
subScenario: `multiFile/detects deleted file`,
|
||||
commandLineArgs: ["--b", "/src/main/tsconfig.json", "-v", "--traceResolution", "--explainFiles"],
|
||||
fs: () => fs({ composite: true }, { composite: true }),
|
||||
edits: [{
|
||||
@@ -57,7 +57,7 @@ describe("unittests:: tsbuild:: fileDelete::", () => {
|
||||
|
||||
verifyTsc({
|
||||
scenario: "fileDelete",
|
||||
subScenario: `detects deleted file with outFile`,
|
||||
subScenario: `outFile/detects deleted file`,
|
||||
commandLineArgs: ["--b", "/src/main/tsconfig.json", "-v", "--traceResolution", "--explainFiles"],
|
||||
fs: () => fs({ composite: true, outFile: "../childResult.js", module: ts.ModuleKind.AMD }, { composite: true, outFile: "../mainResult.js", module: ts.ModuleKind.AMD }),
|
||||
edits: [{
|
||||
@@ -68,7 +68,7 @@ describe("unittests:: tsbuild:: fileDelete::", () => {
|
||||
|
||||
verifyTsc({
|
||||
scenario: "fileDelete",
|
||||
subScenario: `deleted file without composite`,
|
||||
subScenario: `multiFile/deleted file without composite`,
|
||||
commandLineArgs: ["--b", "/src/child/tsconfig.json", "-v", "--traceResolution", "--explainFiles"],
|
||||
fs: () => fs({}),
|
||||
edits: [{
|
||||
@@ -82,7 +82,7 @@ describe("unittests:: tsbuild:: fileDelete::", () => {
|
||||
|
||||
verifyTsc({
|
||||
scenario: "fileDelete",
|
||||
subScenario: `deleted file with outFile without composite`,
|
||||
subScenario: `outFile/deleted file without composite`,
|
||||
commandLineArgs: ["--b", "/src/child/tsconfig.json", "-v", "--traceResolution", "--explainFiles"],
|
||||
fs: () => fs({ outFile: "../childResult.js", module: ts.ModuleKind.AMD }),
|
||||
edits: [{
|
||||
|
||||
@@ -6,35 +6,35 @@ import {
|
||||
import { loadProjectFromFiles } from "../helpers/vfs.js";
|
||||
|
||||
describe("unittests:: tsbuild:: noEmit", () => {
|
||||
function verifyNoEmitWorker(subScenario: string, aTsContent: string, commandLineArgs: readonly string[], options?: object) {
|
||||
verifyTsc({
|
||||
scenario: "noEmit",
|
||||
subScenario,
|
||||
fs: () =>
|
||||
loadProjectFromFiles({
|
||||
"/src/a.ts": aTsContent,
|
||||
"/src/tsconfig.json": jsonToReadableText({
|
||||
compilerOptions: { ...options, noEmit: true },
|
||||
function verifyNoEmitWorker(subScenario: string, aTsContent: string, commandLineArgs: readonly string[]) {
|
||||
[{}, { outFile: "../outFile.js" }].forEach(options => {
|
||||
verifyTsc({
|
||||
scenario: "noEmit",
|
||||
subScenario: `${options?.outFile ? "outFile" : "multiFile"}/${subScenario}`,
|
||||
fs: () =>
|
||||
loadProjectFromFiles({
|
||||
"/src/a.ts": aTsContent,
|
||||
"/src/tsconfig.json": jsonToReadableText({
|
||||
compilerOptions: { ...options, noEmit: true },
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
commandLineArgs,
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "Fix error",
|
||||
edit: fs => fs.writeFileSync("/src/a.ts", `const a = "hello"`),
|
||||
},
|
||||
noChangeRun,
|
||||
],
|
||||
baselinePrograms: true,
|
||||
commandLineArgs,
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
caption: "Fix error",
|
||||
edit: fs => fs.writeFileSync("/src/a.ts", `const a = "hello"`),
|
||||
},
|
||||
noChangeRun,
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function verifyNoEmit(subScenario: string, aTsContent: string) {
|
||||
verifyNoEmitWorker(subScenario, aTsContent, ["--b", "/src/tsconfig.json", "-v"]);
|
||||
verifyNoEmitWorker(`${subScenario} with incremental`, aTsContent, ["--b", "/src/tsconfig.json", "-v", "--incremental"]);
|
||||
verifyNoEmitWorker(`${subScenario} with outFile`, aTsContent, ["--b", "/src/tsconfig.json", "-v"], { outFile: "../outFile.js" });
|
||||
verifyNoEmitWorker(`${subScenario} with outFile with incremental`, aTsContent, ["--b", "/src/tsconfig.json", "-v", "--incremental"], { outFile: "../outFile.js" });
|
||||
}
|
||||
|
||||
verifyNoEmit("syntax errors", `const a = "hello`);
|
||||
|
||||
@@ -10,7 +10,7 @@ describe("unittests:: tsbuildWatch:: watchMode:: configFileErrors:: reports synt
|
||||
function verify(outFile?: object) {
|
||||
verifyTscWatch({
|
||||
scenario: "configFileErrors",
|
||||
subScenario: `reports syntax errors in config file${outFile ? " with outFile" : ""}`,
|
||||
subScenario: `${outFile ? "outFile" : "multiFile"}/reports syntax errors in config file`,
|
||||
sys: () =>
|
||||
createWatchedSystem(
|
||||
[
|
||||
|
||||
@@ -10,7 +10,7 @@ describe("unittests:: tsbuildWatch:: watchMode:: with noEmit", () => {
|
||||
function verify(outFile?: object) {
|
||||
verifyTscWatch({
|
||||
scenario: "noEmit",
|
||||
subScenario: `does not go in loop when watching when no files are emitted${outFile ? " with outFile" : ""}`,
|
||||
subScenario: `${outFile ? "outFile" : "multiFile"}/does not go in loop when watching when no files are emitted`,
|
||||
commandLineArgs: ["-b", "-w", "-verbose"],
|
||||
sys: () =>
|
||||
createWatchedSystem({
|
||||
|
||||
@@ -497,96 +497,65 @@ console.log(a);`,
|
||||
},
|
||||
};
|
||||
}
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "different options",
|
||||
fs: () => fs({ composite: true }),
|
||||
commandLineArgs: ["--p", "/src/project"],
|
||||
edits: [
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("should re-emit only js so they dont contain sourcemap"),
|
||||
withOptionChangeAndDiscrepancyExplanation("with declaration should not emit anything", "--declaration"),
|
||||
noChangeRun,
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
noChangeWithSubscenario("should re-emit only dts so they dont contain sourcemap"),
|
||||
withOptionChangeAndDiscrepancyExplanation("with emitDeclarationOnly should not emit anything", "--emitDeclarationOnly"),
|
||||
noChangeRun,
|
||||
localChange(),
|
||||
withOptionChangeAndDiscrepancyExplanation("with declaration should not emit anything", "--declaration"),
|
||||
withOptionChange("with inlineSourceMap", "--inlineSourceMap"),
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
enableDeclarationMap(),
|
||||
withOptionChange("with sourceMap should not emit d.ts", "--sourceMap"),
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "different options with outFile",
|
||||
fs: () => fs({ composite: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD }),
|
||||
commandLineArgs: ["--p", "/src/project"],
|
||||
edits: [
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("should re-emit only js so they dont contain sourcemap"),
|
||||
withOptionChangeAndDiscrepancyExplanation("with declaration should not emit anything", "--declaration"),
|
||||
noChangeRun,
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
noChangeWithSubscenario("should re-emit only dts so they dont contain sourcemap"),
|
||||
withEmitDeclarationOnlyChangeAndDiscrepancyExplanation("with emitDeclarationOnly should not emit anything"),
|
||||
noChangeRun,
|
||||
localChange(),
|
||||
withOptionChangeAndDiscrepancyExplanation("with declaration should not emit anything", "--declaration"),
|
||||
withOptionChange("with inlineSourceMap", "--inlineSourceMap"),
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
enableDeclarationMap(),
|
||||
withOptionChange("with sourceMap should not emit d.ts", "--sourceMap"),
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "different options with incremental",
|
||||
fs: () => fs({ incremental: true }),
|
||||
commandLineArgs: ["--p", "/src/project"],
|
||||
edits: [
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
withOptionChange("should re-emit only js so they dont contain sourcemap"),
|
||||
withOptionChange("with declaration, emit Dts and should not emit js", "--declaration"),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
nochangeWithIncrementalDeclarationFromBeforeExplaination(),
|
||||
localChange(),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
nochangeWithIncrementalDeclarationFromBeforeExplaination(),
|
||||
withOptionChange("with inlineSourceMap", "--inlineSourceMap"),
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("emit js files"),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
withOptionChange("with declaration and declarationMap, should not re-emit", "--declaration", "--declarationMap"),
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "different options with incremental with outFile",
|
||||
fs: () => fs({ incremental: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD }),
|
||||
commandLineArgs: ["--p", "/src/project"],
|
||||
edits: [
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("should re-emit only js so they dont contain sourcemap"),
|
||||
withOptionChange("with declaration, emit Dts and should not emit js", "--declaration"),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
nochangeWithIncrementalOutDeclarationFromBeforeExplaination(),
|
||||
localChange(),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
nochangeWithIncrementalOutDeclarationFromBeforeExplaination(),
|
||||
withOptionChange("with inlineSourceMap", "--inlineSourceMap"),
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("emit js files"),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
withOptionChange("with declaration and declarationMap, should not re-emit", "--declaration", "--declarationMap"),
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
function verify(options: ts.CompilerOptions) {
|
||||
function scenarioName(text: string) {
|
||||
return `${options.outFile ? "outFile" : "multiFile"}/${text}`;
|
||||
}
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: scenarioName("different options"),
|
||||
fs: () => fs({ composite: true, ...options }),
|
||||
commandLineArgs: ["--p", "/src/project"],
|
||||
edits: [
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("should re-emit only js so they dont contain sourcemap"),
|
||||
withOptionChangeAndDiscrepancyExplanation("with declaration should not emit anything", "--declaration"),
|
||||
noChangeRun,
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
noChangeWithSubscenario("should re-emit only dts so they dont contain sourcemap"),
|
||||
!options.outFile ?
|
||||
withOptionChangeAndDiscrepancyExplanation("with emitDeclarationOnly should not emit anything", "--emitDeclarationOnly") :
|
||||
withEmitDeclarationOnlyChangeAndDiscrepancyExplanation("with emitDeclarationOnly should not emit anything"),
|
||||
noChangeRun,
|
||||
localChange(),
|
||||
withOptionChangeAndDiscrepancyExplanation("with declaration should not emit anything", "--declaration"),
|
||||
withOptionChange("with inlineSourceMap", "--inlineSourceMap"),
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
enableDeclarationMap(),
|
||||
withOptionChange("with sourceMap should not emit d.ts", "--sourceMap"),
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: scenarioName("different options with incremental"),
|
||||
fs: () => fs({ incremental: true, ...options }),
|
||||
commandLineArgs: ["--p", "/src/project"],
|
||||
edits: [
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("should re-emit only js so they dont contain sourcemap"),
|
||||
withOptionChange("with declaration, emit Dts and should not emit js", "--declaration"),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
!options.outFile ?
|
||||
nochangeWithIncrementalDeclarationFromBeforeExplaination() :
|
||||
nochangeWithIncrementalOutDeclarationFromBeforeExplaination(),
|
||||
localChange(),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
!options.outFile ?
|
||||
nochangeWithIncrementalDeclarationFromBeforeExplaination() :
|
||||
nochangeWithIncrementalOutDeclarationFromBeforeExplaination(),
|
||||
withOptionChange("with inlineSourceMap", "--inlineSourceMap"),
|
||||
withOptionChange("with sourceMap", "--sourceMap"),
|
||||
noChangeWithSubscenario("emit js files"),
|
||||
withOptionChange("with declaration and declarationMap", "--declaration", "--declarationMap"),
|
||||
withOptionChange("with declaration and declarationMap, should not re-emit", "--declaration", "--declarationMap"),
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
}
|
||||
|
||||
verify({});
|
||||
verify({ outFile: "../outFile.js", module: ts.ModuleKind.AMD });
|
||||
});
|
||||
|
||||
verifyTsc({
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as ts from "../../_namespaces/ts.js";
|
||||
import { dedent } from "../../_namespaces/Utils.js";
|
||||
import { jsonToReadableText } from "../helpers.js";
|
||||
import { compilerOptionsToConfigJson } from "../helpers/contents.js";
|
||||
import {
|
||||
noChangeOnlyRuns,
|
||||
noChangeRun,
|
||||
@@ -16,9 +17,9 @@ describe("unittests:: tsc:: noEmit::", () => {
|
||||
verifyNoEmitChanges({ incremental: true });
|
||||
verifyNoEmitChanges({ incremental: true, declaration: true });
|
||||
verifyNoEmitChanges({ composite: true });
|
||||
verifyNoEmitChanges({ incremental: true, outFile: "../outFile.js" });
|
||||
verifyNoEmitChanges({ incremental: true, declaration: true, outFile: "../outFile.js" });
|
||||
verifyNoEmitChanges({ composite: true, outFile: "../outFile.js" });
|
||||
verifyNoEmitChanges({ incremental: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD });
|
||||
verifyNoEmitChanges({ incremental: true, declaration: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD });
|
||||
verifyNoEmitChanges({ composite: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD });
|
||||
|
||||
function verifyNoEmitChanges(compilerOptions: ts.CompilerOptions) {
|
||||
const discrepancyExplanation = () => [
|
||||
@@ -40,14 +41,17 @@ describe("unittests:: tsc:: noEmit::", () => {
|
||||
};
|
||||
let optionsString = "";
|
||||
for (const key in compilerOptions) {
|
||||
if (ts.hasProperty(compilerOptions, key)) {
|
||||
if (ts.hasProperty(compilerOptions, key) && key !== "outFile" && key !== "module") {
|
||||
optionsString += ` ${key}`;
|
||||
}
|
||||
}
|
||||
function scenarioName(text: string) {
|
||||
return `${compilerOptions.outFile ? "outFile" : "multiFile"}/${text}${optionsString}`;
|
||||
}
|
||||
|
||||
verifyTsc({
|
||||
scenario: "noEmit",
|
||||
subScenario: `changes${optionsString}`,
|
||||
subScenario: scenarioName("changes"),
|
||||
commandLineArgs: ["--p", "src/project"],
|
||||
fs,
|
||||
edits: [
|
||||
@@ -94,7 +98,7 @@ describe("unittests:: tsc:: noEmit::", () => {
|
||||
|
||||
verifyTsc({
|
||||
scenario: "noEmit",
|
||||
subScenario: `changes with initial noEmit${optionsString}`,
|
||||
subScenario: scenarioName("changes with initial noEmit"),
|
||||
commandLineArgs: ["--p", "src/project", "--noEmit"],
|
||||
fs,
|
||||
edits: [
|
||||
@@ -138,7 +142,9 @@ describe("unittests:: tsc:: noEmit::", () => {
|
||||
"/src/project/src/noChangeFileWithEmitSpecificError.ts": dedent`
|
||||
function someFunc(arguments: boolean, ...rest: any[]) {
|
||||
}`,
|
||||
"/src/project/tsconfig.json": jsonToReadableText({ compilerOptions }),
|
||||
"/src/project/tsconfig.json": jsonToReadableText({
|
||||
compilerOptions: compilerOptionsToConfigJson(compilerOptions),
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ const a: string = 10;`,
|
||||
|
||||
verifyTsc({
|
||||
scenario: "noEmitOnError",
|
||||
subScenario: `when declarationMap changes`,
|
||||
subScenario: `multiFile/when declarationMap changes`,
|
||||
fs: () =>
|
||||
loadProjectFromFiles({
|
||||
"/src/project/tsconfig.json": jsonToReadableText({
|
||||
@@ -104,7 +104,7 @@ const a: string = 10;`,
|
||||
|
||||
verifyTsc({
|
||||
scenario: "noEmitOnError",
|
||||
subScenario: `when declarationMap changes with outFile`,
|
||||
subScenario: `outFile/when declarationMap changes`,
|
||||
fs: () =>
|
||||
loadProjectFromFiles({
|
||||
"/src/project/tsconfig.json": jsonToReadableText({
|
||||
@@ -135,7 +135,7 @@ const a: string = 10;`,
|
||||
|
||||
verifyTsc({
|
||||
scenario: "noEmitOnError",
|
||||
subScenario: "file deleted before fixing error with noEmitOnError",
|
||||
subScenario: "multiFile/file deleted before fixing error with noEmitOnError",
|
||||
fs: () =>
|
||||
loadProjectFromFiles({
|
||||
"/src/project/tsconfig.json": jsonToReadableText({
|
||||
@@ -157,7 +157,7 @@ const a: string = 10;`,
|
||||
|
||||
verifyTsc({
|
||||
scenario: "noEmitOnError",
|
||||
subScenario: "file deleted before fixing error with noEmitOnError with outFile",
|
||||
subScenario: "outFile/file deleted before fixing error with noEmitOnError",
|
||||
fs: () =>
|
||||
loadProjectFromFiles({
|
||||
"/src/project/tsconfig.json": jsonToReadableText({
|
||||
|
||||
@@ -342,10 +342,10 @@ describe("unittests:: tsc-watch:: watchAPI:: when watchHost uses createSemanticD
|
||||
|
||||
function verify(outFileOptions: ts.CompilerOptions | undefined) {
|
||||
function scenarioName(scenario: string) {
|
||||
return `${scenario}${outFileOptions ? "with outFile" : ""}`;
|
||||
return `${outFileOptions ? "outFile" : "multiFile"}/${scenario}`;
|
||||
}
|
||||
function baselineName(baseline: string) {
|
||||
return `tscWatch/watchApi/${baseline}${outFileOptions ? "-outFile" : ""}.js`;
|
||||
return `tscWatch/watchApi/${outFileOptions ? "outFile" : "multiFile"}/${baseline}.js`;
|
||||
}
|
||||
it(scenarioName("verifies that noEmit is handled on createSemanticDiagnosticsBuilderProgram and typechecking happens only on affected files"), () => {
|
||||
const { sys, baseline, cb, getPrograms, config, mainFile } = createSystem("{}", "export const x = 10;");
|
||||
@@ -451,50 +451,50 @@ describe("unittests:: tsc-watch:: watchAPI:: when watchHost uses createSemanticD
|
||||
Harness.Baseline.runBaseline(baselineName("noEmitOnError-with-composite-with-emit-builder"), emitBaseline.join("\r\n"));
|
||||
});
|
||||
});
|
||||
|
||||
it(scenarioName("SemanticDiagnosticsBuilderProgram emitDtsOnly does not update affected files pending emit"), () => {
|
||||
// Initial
|
||||
const { sys, baseline, config, mainFile } = createSystem(jsonToReadableText({ compilerOptions: { composite: true, noEmitOnError: true, ...outFileOptions ? compilerOptionsToConfigJson(outFileOptions) : undefined } }), "export const x: string = 10;");
|
||||
createWatch(baseline, config, sys, ts.createSemanticDiagnosticsBuilderProgram);
|
||||
|
||||
// Fix error and emit
|
||||
applyEdit(sys, baseline, sys => sys.writeFile(mainFile.path, "export const x = 10;"), "Fix error");
|
||||
|
||||
const { cb, getPrograms } = commandLineCallbacks(sys);
|
||||
const reportDiagnostic = ts.createDiagnosticReporter(sys, /*pretty*/ true);
|
||||
const reportWatchStatus = ts.createWatchStatusReporter(sys, /*pretty*/ true);
|
||||
const host = ts.createWatchCompilerHostOfConfigFile({
|
||||
configFileName: config.path,
|
||||
createProgram: ts.createSemanticDiagnosticsBuilderProgram,
|
||||
system: sys,
|
||||
reportDiagnostic,
|
||||
reportWatchStatus,
|
||||
});
|
||||
host.afterProgramCreate = program => {
|
||||
const diagnostics = ts.sortAndDeduplicateDiagnostics(program.getSemanticDiagnostics());
|
||||
diagnostics.forEach(reportDiagnostic);
|
||||
// Buildinfo should still have affectedFilesPendingEmit since we are only emitting dts files
|
||||
program.emit(/*targetSourceFile*/ undefined, /*writeFile*/ undefined, /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ true);
|
||||
reportWatchStatus(
|
||||
ts.createCompilerDiagnostic(ts.getWatchErrorSummaryDiagnosticMessage(diagnostics.length), diagnostics.length),
|
||||
sys.newLine,
|
||||
program.getCompilerOptions(),
|
||||
diagnostics.length,
|
||||
);
|
||||
cb(program);
|
||||
};
|
||||
ts.createWatchProgram(host);
|
||||
watchBaseline({
|
||||
baseline,
|
||||
getPrograms,
|
||||
oldPrograms: ts.emptyArray,
|
||||
sys,
|
||||
});
|
||||
Harness.Baseline.runBaseline(baselineName("semantic-builder-emitOnlyDts"), baseline.join("\r\n"));
|
||||
});
|
||||
}
|
||||
verify(/*outFileOptions*/ undefined);
|
||||
verify({ outFile: "../outFile.js", module: ts.ModuleKind.AMD });
|
||||
|
||||
it("SemanticDiagnosticsBuilderProgram emitDtsOnly does not update affected files pending emit", () => {
|
||||
// Initial
|
||||
const { sys, baseline, config, mainFile } = createSystem(jsonToReadableText({ compilerOptions: { composite: true, noEmitOnError: true } }), "export const x: string = 10;");
|
||||
createWatch(baseline, config, sys, ts.createSemanticDiagnosticsBuilderProgram);
|
||||
|
||||
// Fix error and emit
|
||||
applyEdit(sys, baseline, sys => sys.writeFile(mainFile.path, "export const x = 10;"), "Fix error");
|
||||
|
||||
const { cb, getPrograms } = commandLineCallbacks(sys);
|
||||
const reportDiagnostic = ts.createDiagnosticReporter(sys, /*pretty*/ true);
|
||||
const reportWatchStatus = ts.createWatchStatusReporter(sys, /*pretty*/ true);
|
||||
const host = ts.createWatchCompilerHostOfConfigFile({
|
||||
configFileName: config.path,
|
||||
createProgram: ts.createSemanticDiagnosticsBuilderProgram,
|
||||
system: sys,
|
||||
reportDiagnostic,
|
||||
reportWatchStatus,
|
||||
});
|
||||
host.afterProgramCreate = program => {
|
||||
const diagnostics = ts.sortAndDeduplicateDiagnostics(program.getSemanticDiagnostics());
|
||||
diagnostics.forEach(reportDiagnostic);
|
||||
// Buildinfo should still have affectedFilesPendingEmit since we are only emitting dts files
|
||||
program.emit(/*targetSourceFile*/ undefined, /*writeFile*/ undefined, /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ true);
|
||||
reportWatchStatus(
|
||||
ts.createCompilerDiagnostic(ts.getWatchErrorSummaryDiagnosticMessage(diagnostics.length), diagnostics.length),
|
||||
sys.newLine,
|
||||
program.getCompilerOptions(),
|
||||
diagnostics.length,
|
||||
);
|
||||
cb(program);
|
||||
};
|
||||
ts.createWatchProgram(host);
|
||||
watchBaseline({
|
||||
baseline,
|
||||
getPrograms,
|
||||
oldPrograms: ts.emptyArray,
|
||||
sys,
|
||||
});
|
||||
Harness.Baseline.runBaseline(`tscWatch/watchApi/semantic-builder-emitOnlyDts.js`, baseline.join("\r\n"));
|
||||
});
|
||||
});
|
||||
|
||||
describe("unittests:: tsc-watch:: watchAPI:: when getParsedCommandLine is implemented", () => {
|
||||
@@ -722,8 +722,8 @@ describe("unittests:: tsc-watch:: watchAPI:: when builder emit occurs with emitO
|
||||
}
|
||||
});
|
||||
}
|
||||
verify("when emitting with emitOnlyDtsFiles");
|
||||
verify("when emitting with emitOnlyDtsFiles with outFile", "outFile.js");
|
||||
verify("multiFile/when emitting with emitOnlyDtsFiles");
|
||||
verify("outFile/when emitting with emitOnlyDtsFiles", "outFile.js");
|
||||
});
|
||||
|
||||
describe("unittests:: tsc-watch:: watchAPI:: when creating program with project references but not config file", () => {
|
||||
|
||||
+5
-5
@@ -104,8 +104,6 @@ IncrementalBuild:
|
||||
6:: with emitDeclarationOnly should not emit anything
|
||||
Clean build tsbuildinfo will have compilerOptions with composite and emitDeclarationOnly
|
||||
Incremental build will detect that it doesnt need to rebuild so tsbuild info is from before which has option composite only
|
||||
Clean build info does not have js section because its fresh build
|
||||
Incremental build info has js section from old build
|
||||
TsBuild info text without affectedFilesPendingEmit:: /src/outfile.tsbuildinfo.readable.baseline.txt::
|
||||
CleanBuild:
|
||||
{
|
||||
@@ -206,9 +204,11 @@ IncrementalBuild:
|
||||
},
|
||||
"version": "FakeTSVersion"
|
||||
}
|
||||
9:: with declaration should not emit anything
|
||||
Clean build tsbuildinfo will have compilerOptions with composite and declaration
|
||||
9:: with emitDeclarationOnly should not emit anything
|
||||
Clean build tsbuildinfo will have compilerOptions with composite and emitDeclarationOnly
|
||||
Incremental build will detect that it doesnt need to rebuild so tsbuild info is from before which has option composite only
|
||||
Clean build info does not have js section because its fresh build
|
||||
Incremental build info has js section from old build
|
||||
TsBuild info text without affectedFilesPendingEmit:: /src/outfile.tsbuildinfo.readable.baseline.txt::
|
||||
CleanBuild:
|
||||
{
|
||||
@@ -251,7 +251,7 @@ CleanBuild:
|
||||
],
|
||||
"options": {
|
||||
"composite": true,
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"module": 2,
|
||||
"outFile": "./outFile.js"
|
||||
},
|
||||
+2
-2
@@ -1006,12 +1006,12 @@ define("d", ["require", "exports", "b"], function (require, exports, b_1) {
|
||||
|
||||
|
||||
|
||||
Change:: with declaration should not emit anything
|
||||
Change:: with emitDeclarationOnly should not emit anything
|
||||
Input::
|
||||
|
||||
|
||||
Output::
|
||||
/lib/tsc --b /src/project --verbose --declaration
|
||||
/lib/tsc --b /src/project --verbose --emitDeclarationOnly
|
||||
[[90mHH:MM:SS AM[0m] Projects in this build:
|
||||
* src/project/tsconfig.json
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user