Skip to content

Commit 133a86a

Browse files
committed
Conflict with Object.prototype.watch in FireFox/Gecko
In Gecko engine `commandLine.options.watch` evaluates to a truthy value (a function). Adding an extra check to work around. [Definition of CompilerOptions.watch in compiler/types](https://github.com/Microsoft/TypeScript/blob/master/src/compiler/types.ts#L1860) ``` typescript export interface CompilerOptions { // . . . watch?: boolean; ``` [Object.prototype.watch on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/watch) > Warning: Generally you should avoid using watch() and unwatch() when possible. These two methods are > implemented only in Gecko, and they're intended primarily for debugging use. In addition, using watchpoints > has a serious negative impact on performance, which is especially true when used on global objects, such > as window. You can usually use setters and getters or proxies instead. See Browser compatibility for details. > Also, do not confuse Object.watch with Object.observe.
1 parent d695afa commit 133a86a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/compiler/tsc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ namespace ts {
191191
return sys.exit(ExitStatus.Success);
192192
}
193193

194-
if (commandLine.options.watch) {
194+
if (commandLine.options.watch && commandLine.options.hasOwnProperty('watch')) { // FireFox has Object.prototype.watch
195195
if (!sys.watchFile) {
196196
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
197197
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);

0 commit comments

Comments
 (0)