From d07a2774a31414b617560280e1613361d595d8ca Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 27 Oct 2015 13:48:37 -0700 Subject: [PATCH 1/2] const enum fixing in postprocess step --- Jakefile.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jakefile.js b/Jakefile.js index 23720a2e7c2e4..bff7c118697bc 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -444,6 +444,8 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca // Stanalone/web definition file using global 'ts' namespace jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true}); var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString(); + definitionFileContents = definitionFileContents.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4'); + fs.writeFileSync(standaloneDefinitionsFile, definitionFileContents); // Official node package definition file, pointed to by 'typings' in package.json // Created by appending 'export = ts;' at the end of the standalone file to turn it into an external module From b0764582ced07415b42a800d707158c6be5d5c11 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 27 Oct 2015 16:24:19 -0700 Subject: [PATCH 2/2] accept api test baslines --- .../baselines/reference/APISample_compile.js | 2 +- tests/baselines/reference/APISample_linter.js | 24 +++++++++---------- .../reference/APISample_transform.js | 2 +- .../baselines/reference/APISample_watcher.js | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index f30bd2c21a945..694730e61c4b3 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -57,5 +57,5 @@ function compile(fileNames, options) { exports.compile = compile; compile(process.argv.slice(2), { noEmitOnError: true, noImplicitAny: true, - target: 1 /* ES5 */, module: 1 /* CommonJS */ + target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS }); diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index aeff3a327f557..b7b2a93ba87b0 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -75,28 +75,28 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 199 /* ForStatement */: - case 200 /* ForInStatement */: - case 198 /* WhileStatement */: - case 197 /* DoStatement */: - if (node.statement.kind !== 192 /* Block */) { + case ts.SyntaxKind.ForStatement: + case ts.SyntaxKind.ForInStatement: + case ts.SyntaxKind.WhileStatement: + case ts.SyntaxKind.DoStatement: + if (node.statement.kind !== ts.SyntaxKind.Block) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 196 /* IfStatement */: + case ts.SyntaxKind.IfStatement: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 192 /* Block */) { + if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 192 /* Block */ && - ifStatement.elseStatement.kind !== 196 /* IfStatement */) { + ifStatement.elseStatement.kind !== ts.SyntaxKind.Block && + ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 181 /* BinaryExpression */: + case ts.SyntaxKind.BinaryExpression: var op = node.operatorToken.kind; - if (op === 30 /* EqualsEqualsToken */ || op == 31 /* ExclamationEqualsToken */) { + if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) { report(node, "Use '===' and '!=='."); } break; @@ -112,7 +112,7 @@ exports.delint = delint; var fileNames = process.argv.slice(2); fileNames.forEach(function (fileName) { // Parse a file - var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), 2 /* ES6 */, /*setParentNodes */ true); + var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); // delint it delint(sourceFile); }); diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index a7f83f19b5e91..0f22b8486dc4b 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -24,5 +24,5 @@ console.log(JSON.stringify(result)); */ var ts = require("typescript"); var source = "let x: string = 'string'"; -var result = ts.transpile(source, { module: 1 /* CommonJS */ }); +var result = ts.transpile(source, { module: ts.ModuleKind.CommonJS }); console.log(JSON.stringify(result)); diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index e2ab4e135ddb4..0b31ca3c7bfe8 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -181,4 +181,4 @@ function watch(rootFileNames, options) { var currentDirectoryFiles = fs.readdirSync(process.cwd()). filter(function (fileName) { return fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts"; }); // Start the watcher -watch(currentDirectoryFiles, { module: 1 /* CommonJS */ }); +watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS });