Skip to content

Commit 11d7f4f

Browse files
committed
Handle displaying of watchOptions
1 parent 985a9b6 commit 11d7f4f

File tree

8 files changed

+155
-70
lines changed

8 files changed

+155
-70
lines changed

src/compiler/builder.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ namespace ts {
743743

744744
function convertToReusableCompilerOptions(options: CompilerOptions, relativeToBuildInfo: (path: string) => string) {
745745
const result: CompilerOptions = {};
746-
const optionsNameMap = getOptionNameMap().optionNameMap;
746+
const { optionsNameMap } = getOptionsNameMap();
747747

748748
for (const name in options) {
749749
if (hasProperty(options, name)) {
@@ -1183,4 +1183,4 @@ namespace ts {
11831183
return Debug.assertDefined(state.program);
11841184
}
11851185
}
1186-
}
1186+
}

src/compiler/commandLineParser.ts

+92-60
Large diffs are not rendered by default.

src/testRunner/unittests/config/showConfig.ts

+28-8
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,33 @@ namespace ts {
102102
]
103103
});
104104

105+
showTSConfigCorrectly("Show TSConfig with watch options", ["-p", "tsconfig.json"], {
106+
watchOptions: {
107+
watchFile: "DynamicPriorityPolling"
108+
},
109+
include: [
110+
"./src/**/*"
111+
]
112+
});
113+
105114
// Bulk validation of all option declarations
106115
for (const option of optionDeclarations) {
107-
if (option.name === "project") continue;
108-
let configObject: object | undefined;
116+
baselineOption(option, /*isCompilerOptions*/ true);
117+
}
118+
119+
for (const option of optionsForWatch) {
120+
baselineOption(option, /*isCompilerOptions*/ false);
121+
}
122+
123+
function baselineOption(option: CommandLineOption, isCompilerOptions: boolean) {
124+
if (option.name === "project") return;
109125
let args: string[];
126+
let optionValue: object | undefined;
110127
switch (option.type) {
111128
case "boolean": {
112129
if (option.isTSConfigOnly) {
113130
args = ["-p", "tsconfig.json"];
114-
configObject = { compilerOptions: { [option.name]: true } };
131+
optionValue = { [option.name]: true };
115132
}
116133
else {
117134
args = [`--${option.name}`];
@@ -121,7 +138,7 @@ namespace ts {
121138
case "list": {
122139
if (option.isTSConfigOnly) {
123140
args = ["-p", "tsconfig.json"];
124-
configObject = { compilerOptions: { [option.name]: [] } };
141+
optionValue = { [option.name]: [] };
125142
}
126143
else {
127144
args = [`--${option.name}`];
@@ -131,7 +148,7 @@ namespace ts {
131148
case "string": {
132149
if (option.isTSConfigOnly) {
133150
args = ["-p", "tsconfig.json"];
134-
configObject = { compilerOptions: { [option.name]: "someString" } };
151+
optionValue = { [option.name]: "someString" };
135152
}
136153
else {
137154
args = [`--${option.name}`, "someString"];
@@ -141,7 +158,7 @@ namespace ts {
141158
case "number": {
142159
if (option.isTSConfigOnly) {
143160
args = ["-p", "tsconfig.json"];
144-
configObject = { compilerOptions: { [option.name]: 0 } };
161+
optionValue = { [option.name]: 0 };
145162
}
146163
else {
147164
args = [`--${option.name}`, "0"];
@@ -150,7 +167,7 @@ namespace ts {
150167
}
151168
case "object": {
152169
args = ["-p", "tsconfig.json"];
153-
configObject = { compilerOptions: { [option.name]: {} } };
170+
optionValue = { [option.name]: {} };
154171
break;
155172
}
156173
default: {
@@ -159,14 +176,17 @@ namespace ts {
159176
const val = iterResult.value;
160177
if (option.isTSConfigOnly) {
161178
args = ["-p", "tsconfig.json"];
162-
configObject = { compilerOptions: { [option.name]: val } };
179+
optionValue = { [option.name]: val };
163180
}
164181
else {
165182
args = [`--${option.name}`, val];
166183
}
167184
break;
168185
}
169186
}
187+
188+
const configObject = optionValue &&
189+
(isCompilerOptions ? { compilerOptions: optionValue } : { watchOptions: optionValue });
170190
showTSConfigCorrectly(`Shows tsconfig for single option/${option.name}`, args, configObject);
171191
}
172192
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {},
3+
"watchOptions": {
4+
"watchFile": "dynamicprioritypolling"
5+
},
6+
"include": [
7+
"./src/**/*"
8+
]
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {},
3+
"watchOptions": {
4+
"fallbackPolling": "fixedinterval"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {},
3+
"watchOptions": {
4+
"synchronousWatchDirectory": true
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {},
3+
"watchOptions": {
4+
"watchDirectory": "usefsevents"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {},
3+
"watchOptions": {
4+
"watchFile": "fixedpollinginterval"
5+
}
6+
}

0 commit comments

Comments
 (0)