diff --git a/scripts/processDiagnosticMessages.ts b/scripts/processDiagnosticMessages.ts
index 431cf460180..e5eaa46c8e5 100644
--- a/scripts/processDiagnosticMessages.ts
+++ b/scripts/processDiagnosticMessages.ts
@@ -86,7 +86,7 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
'/// \r\n' +
'/* @internal */\r\n' +
'namespace ts {\r\n' +
- ' export var Diagnostics = {\r\n';
+ ' export const Diagnostics = {\r\n';
var names = Utilities.getObjectKeys(messageTable);
for (var i = 0; i < names.length; i++) {
var name = names[i];
diff --git a/src/compiler/core.ts b/src/compiler/core.ts
index 4e1f4553642..e63bcbf8474 100644
--- a/src/compiler/core.ts
+++ b/src/compiler/core.ts
@@ -212,7 +212,7 @@ namespace ts {
* true for all elements, otherwise returns a new array instance containing the filtered subset.
*/
export function filter(array: T[], f: (x: T) => x is U): U[];
- export function filter(array: T[], f: (x: T) => boolean): T[]
+ export function filter(array: T[], f: (x: T) => boolean): T[];
export function filter(array: T[], f: (x: T) => boolean): T[] {
if (array) {
const len = array.length;
@@ -1867,10 +1867,10 @@ namespace ts {
declare var process: any;
declare var require: any;
- let currentAssertionLevel: AssertionLevel;
+ export let currentAssertionLevel = AssertionLevel.None;
export function shouldAssert(level: AssertionLevel): boolean {
- return getCurrentAssertionLevel() >= level;
+ return currentAssertionLevel >= level;
}
export function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void {
@@ -1887,35 +1887,6 @@ namespace ts {
export function fail(message?: string): void {
Debug.assert(/*expression*/ false, message);
}
-
- function getCurrentAssertionLevel() {
- if (currentAssertionLevel !== undefined) {
- return currentAssertionLevel;
- }
-
- if (sys === undefined) {
- return AssertionLevel.None;
- }
-
- const developmentMode = /^development$/i.test(getEnvironmentVariable("NODE_ENV"));
- currentAssertionLevel = developmentMode
- ? AssertionLevel.Normal
- : AssertionLevel.None;
-
- return currentAssertionLevel;
- }
- }
-
- export function getEnvironmentVariable(name: string, host?: CompilerHost) {
- if (host && host.getEnvironmentVariable) {
- return host.getEnvironmentVariable(name);
- }
-
- if (sys && sys.getEnvironmentVariable) {
- return sys.getEnvironmentVariable(name);
- }
-
- return "";
}
/** Remove an item from an array, moving everything to its right one space left. */
diff --git a/src/compiler/program.ts b/src/compiler/program.ts
index 91adb09c402..5d46038b2b1 100644
--- a/src/compiler/program.ts
+++ b/src/compiler/program.ts
@@ -206,7 +206,7 @@ namespace ts {
readFile: fileName => sys.readFile(fileName),
trace: (s: string) => sys.write(s + newLine),
directoryExists: directoryName => sys.directoryExists(directoryName),
- getEnvironmentVariable: name => getEnvironmentVariable(name, /*host*/ undefined),
+ getEnvironmentVariable: name => sys.getEnvironmentVariable ? sys.getEnvironmentVariable(name) : "",
getDirectories: (path: string) => sys.getDirectories(path),
realpath
};
diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts
index 2d4fcd241aa..7cf7d75bc02 100644
--- a/src/compiler/sys.ts
+++ b/src/compiler/sys.ts
@@ -83,7 +83,7 @@ namespace ts {
getEnvironmentVariable?(name: string): string;
};
- export var sys: System = (function() {
+ export let sys: System = (function() {
function getWScriptSystem(): System {
@@ -637,4 +637,10 @@ namespace ts {
}
return sys;
})();
+
+ if (sys && sys.getEnvironmentVariable) {
+ Debug.currentAssertionLevel = /^development$/i.test(sys.getEnvironmentVariable("NODE_ENV"))
+ ? AssertionLevel.Normal
+ : AssertionLevel.None;
+ }
}
diff --git a/src/harness/harness.ts b/src/harness/harness.ts
index c6b6b460fca..7c82aeece78 100644
--- a/src/harness/harness.ts
+++ b/src/harness/harness.ts
@@ -509,7 +509,7 @@ namespace Harness {
tryEnableSourceMapsForHost?(): void;
getEnvironmentVariable?(name: string): string;
}
- export var IO: IO;
+ export let IO: IO;
// harness always uses one kind of new line
const harnessNewLine = "\r\n";
diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts
index 2b28e66bf88..51310c90a6b 100644
--- a/src/server/editorServices.ts
+++ b/src/server/editorServices.ts
@@ -12,7 +12,7 @@ namespace ts.server {
export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;
export type ProjectServiceEvent =
- { eventName: "context", data: { project: Project, fileName: NormalizedPath } } | { eventName: "configFileDiag", data: { triggerFile?: string, configFileName: string, diagnostics: Diagnostic[] } }
+ { eventName: "context", data: { project: Project, fileName: NormalizedPath } } | { eventName: "configFileDiag", data: { triggerFile?: string, configFileName: string, diagnostics: Diagnostic[] } };
export interface ProjectServiceEventHandler {
(event: ProjectServiceEvent): void;