From 133a86a3773868178d0aa6c53981f8b68087d7a1 Mon Sep 17 00:00:00 2001 From: mihailik Date: Fri, 26 Jun 2015 09:22:55 +0100 Subject: [PATCH 1/3] 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. --- src/compiler/tsc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 2903c3a31f4..eada189d642 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -191,7 +191,7 @@ namespace ts { return sys.exit(ExitStatus.Success); } - if (commandLine.options.watch) { + if (commandLine.options.watch && commandLine.options.hasOwnProperty('watch')) { // FireFox has Object.prototype.watch if (!sys.watchFile) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); From e7e020e958bb4e9ec7942227be32092624a4ee99 Mon Sep 17 00:00:00 2001 From: mihailik Date: Fri, 26 Jun 2015 14:38:25 +0100 Subject: [PATCH 2/3] PR feedback - comments and whitespace adjustments --- src/compiler/tsc.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index eada189d642..1851e516abd 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -191,7 +191,8 @@ namespace ts { return sys.exit(ExitStatus.Success); } - if (commandLine.options.watch && commandLine.options.hasOwnProperty('watch')) { // FireFox has Object.prototype.watch + // Firefox has Object.prototype.watch + if (commandLine.options.watch && commandLine.options.hasOwnProperty('watch')) { if (!sys.watchFile) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); From 72050073bc9d6448dc4c7114b53c4e7fcb9b6ed5 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 26 Jun 2015 10:25:58 -0700 Subject: [PATCH 3/3] use double quotes --- src/compiler/tsc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 1851e516abd..2a01774fbca 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -192,7 +192,7 @@ namespace ts { } // Firefox has Object.prototype.watch - if (commandLine.options.watch && commandLine.options.hasOwnProperty('watch')) { + if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) { if (!sys.watchFile) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);