Skip to content

Const enum deconst'ing #5422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/APISample_compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
24 changes: 12 additions & 12 deletions tests/baselines/reference/APISample_linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
});
2 changes: 1 addition & 1 deletion tests/baselines/reference/APISample_transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
2 changes: 1 addition & 1 deletion tests/baselines/reference/APISample_watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });