Skip to content

Commit

Permalink
Handle displaying of watchOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Dec 10, 2019
1 parent 985a9b6 commit 11d7f4f
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 70 deletions.
4 changes: 2 additions & 2 deletions src/compiler/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ namespace ts {

function convertToReusableCompilerOptions(options: CompilerOptions, relativeToBuildInfo: (path: string) => string) {
const result: CompilerOptions = {};
const optionsNameMap = getOptionNameMap().optionNameMap;
const { optionsNameMap } = getOptionsNameMap();

for (const name in options) {
if (hasProperty(options, name)) {
Expand Down Expand Up @@ -1183,4 +1183,4 @@ namespace ts {
return Debug.assertDefined(state.program);
}
}
}
}
152 changes: 92 additions & 60 deletions src/compiler/commandLineParser.ts

Large diffs are not rendered by default.

36 changes: 28 additions & 8 deletions src/testRunner/unittests/config/showConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,33 @@ namespace ts {
]
});

showTSConfigCorrectly("Show TSConfig with watch options", ["-p", "tsconfig.json"], {
watchOptions: {
watchFile: "DynamicPriorityPolling"
},
include: [
"./src/**/*"
]
});

// Bulk validation of all option declarations
for (const option of optionDeclarations) {
if (option.name === "project") continue;
let configObject: object | undefined;
baselineOption(option, /*isCompilerOptions*/ true);
}

for (const option of optionsForWatch) {
baselineOption(option, /*isCompilerOptions*/ false);
}

function baselineOption(option: CommandLineOption, isCompilerOptions: boolean) {
if (option.name === "project") return;
let args: string[];
let optionValue: object | undefined;
switch (option.type) {
case "boolean": {
if (option.isTSConfigOnly) {
args = ["-p", "tsconfig.json"];
configObject = { compilerOptions: { [option.name]: true } };
optionValue = { [option.name]: true };
}
else {
args = [`--${option.name}`];
Expand All @@ -121,7 +138,7 @@ namespace ts {
case "list": {
if (option.isTSConfigOnly) {
args = ["-p", "tsconfig.json"];
configObject = { compilerOptions: { [option.name]: [] } };
optionValue = { [option.name]: [] };
}
else {
args = [`--${option.name}`];
Expand All @@ -131,7 +148,7 @@ namespace ts {
case "string": {
if (option.isTSConfigOnly) {
args = ["-p", "tsconfig.json"];
configObject = { compilerOptions: { [option.name]: "someString" } };
optionValue = { [option.name]: "someString" };
}
else {
args = [`--${option.name}`, "someString"];
Expand All @@ -141,7 +158,7 @@ namespace ts {
case "number": {
if (option.isTSConfigOnly) {
args = ["-p", "tsconfig.json"];
configObject = { compilerOptions: { [option.name]: 0 } };
optionValue = { [option.name]: 0 };
}
else {
args = [`--${option.name}`, "0"];
Expand All @@ -150,7 +167,7 @@ namespace ts {
}
case "object": {
args = ["-p", "tsconfig.json"];
configObject = { compilerOptions: { [option.name]: {} } };
optionValue = { [option.name]: {} };
break;
}
default: {
Expand All @@ -159,14 +176,17 @@ namespace ts {
const val = iterResult.value;
if (option.isTSConfigOnly) {
args = ["-p", "tsconfig.json"];
configObject = { compilerOptions: { [option.name]: val } };
optionValue = { [option.name]: val };
}
else {
args = [`--${option.name}`, val];
}
break;
}
}

const configObject = optionValue &&
(isCompilerOptions ? { compilerOptions: optionValue } : { watchOptions: optionValue });
showTSConfigCorrectly(`Shows tsconfig for single option/${option.name}`, args, configObject);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {},
"watchOptions": {
"watchFile": "dynamicprioritypolling"
},
"include": [
"./src/**/*"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {},
"watchOptions": {
"fallbackPolling": "fixedinterval"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {},
"watchOptions": {
"synchronousWatchDirectory": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {},
"watchOptions": {
"watchDirectory": "usefsevents"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {},
"watchOptions": {
"watchFile": "fixedpollinginterval"
}
}

0 comments on commit 11d7f4f

Please sign in to comment.