Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
updated to TypeScript 2.2, but some tests are still not passing
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtynjala committed Mar 26, 2017
1 parent 38f7b49 commit 3ce54b7
Show file tree
Hide file tree
Showing 13 changed files with 255 additions and 211 deletions.
26 changes: 11 additions & 15 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,32 @@ gulp.task("clean", function()

gulp.task("build-tests", ["build", "clean-tests"], function()
{
var tsProject = ts.createProject("spec/tsconfig.json");
return gulp.src(
[
"source/*.ts",
"spec/as3/*.ts",
"spec/parser/*.ts",
])
.pipe(ts(
{
module: "commonjs",
target: "ES5",
outDir: "spec/bin"
}))
.pipe(tsProject())
.pipe(gulp.dest("spec/bin"));
});

gulp.task("build", ["clean"], function()
{
var tsProject = ts.createProject("tsconfig.json");
return gulp.src("source/*.ts")
.pipe(ts(
{
module: "commonjs",
target: "ES5"
}))
.pipe(tsProject())
.pipe(gulp.dest("bin"));
});

gulp.task("test", ["build-tests"], function()
{
return gulp.src("spec/bin/spec/**/*.js")
.pipe(jasmine());
return gulp.src("spec/bin/*-spec.js")
.pipe(jasmine(
{
//includeStackTrace: true
}));
});

//tests dts2as with a selection of libraries from DefinitelyTyped.
Expand All @@ -68,8 +64,8 @@ gulp.task("test-definitely-typed", function(callback)
var libraries =
[
[ "node_modules/typescript/lib/lib.d.ts" ],
[ "node_modules/typescript/lib/lib.es6.d.ts" ],
[ "node_modules/typescript/lib/lib.es7.d.ts" ],
[ "node_modules/typescript/lib/lib.es2015.d.ts" ],
[ "node_modules/typescript/lib/lib.es2016.d.ts" ],
[ "node_modules/typescript/lib/typescript.d.ts" ],
[ "node_modules/typescript/lib/typescriptServices.d.ts" ],
[
Expand Down
21 changes: 13 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dts2as",
"version": "0.11.0",
"version": "0.12.0",
"description": "A command line tool that converts TypeScript definitions (d.ts files) to ActionScript 3 classes and interfaces",
"repository": "BowlerHatLLC/dts2as",
"author": "Josh Tynjala",
Expand All @@ -22,15 +22,20 @@
"prepublish": "npm run test"
},
"dependencies": {
"minimist": "^1.1.3",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"rimraf": "^2.4.3",
"typescript": "^1.8.7"
"rimraf": "^2.6.1",
"typescript": "^2.2.1"
},
"devDependencies": {
"del": "^2.1.0",
"gulp": "^3.9.0",
"gulp-jasmine": "^2.2.1",
"gulp-typescript": "^2.12.1"
"@types/jasmine": "^2.5.46",
"@types/minimist": "^1.2.0",
"@types/mkdirp": "^0.3.29",
"@types/node": "^7.0.11",
"@types/rimraf": "0.0.28",
"del": "^2.2.2",
"gulp": "^3.9.1",
"gulp-jasmine": "^2.4.2",
"gulp-typescript": "^3.1.6"
}
}
11 changes: 4 additions & 7 deletions source/as-stub-emitter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2015 Bowler Hat LLC
Copyright 2015-2017 Bowler Hat LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -13,9 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/// <reference path="./as3.ts" />

import as3 = require("./as3");
import * as as3 from "./as3";

let NEW_LINE = "\n";

Expand All @@ -32,7 +31,7 @@ function arrayValues(array: Array<any>): Array<any>
return values;
}

class ASEmitter
export default class
{
constructor(types: as3.PackageLevelDefinition[])
{
Expand Down Expand Up @@ -656,6 +655,4 @@ class ASEmitter
}
return null;
}
}

export = ASEmitter;
}
2 changes: 1 addition & 1 deletion source/as3.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2015 Bowler Hat LLC
Copyright 2015-2017 Bowler Hat LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
65 changes: 37 additions & 28 deletions source/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/// <reference path="../typings/tsd.d.ts" />
/// <reference path="../node_modules/typescript/lib/typescript.d.ts" />

import fs = require("fs");
import path = require("path");
import child_process = require("child_process");
import minimist = require("minimist");
import TS2ASParser = require("./parser");
import ASStubEmitter = require("./as-stub-emitter");
import JSExternsEmitter = require("./js-externs-emitter");
import flexjsUtils = require("./flexjs-utils");
import * as fs from "fs";
import * as path from "path";
import * as child_process from "child_process";
import * as minimist from "minimist";
import * as ts from "typescript";
import * as mkdirp from "mkdirp";
import * as rimraf from "rimraf";
import TS2ASParser from "./parser";
import {DebugLevel} from "./parser";
import ASStubEmitter from "./as-stub-emitter";
import JSExternsEmitter from "./js-externs-emitter";
import {findBinCompc, findFlexHome, isValidApacheFlexJSPath} from "./flexjs-utils";
import as3 = require("./as3");
import ts = require("typescript");
import mkdirp = require("mkdirp");
import rimraf = require("rimraf");

let sourceOutputPathIsTemp = false;
let outputDirectory: string = null;
Expand All @@ -36,7 +35,7 @@ let depsSWCOutputPath: string = null;
let externsOutputPath: string = null;
let flexHome: string = null;
let fileNames: string[];
let debugLevel: TS2ASParser.DebugLevel = TS2ASParser.DebugLevel.NONE;
let debugLevel: DebugLevel = DebugLevel.NONE;
let excludedSymbols: string[];
let includedSymbols: string[];
let scriptTarget: ts.ScriptTarget = ts.ScriptTarget.ES5;
Expand Down Expand Up @@ -105,7 +104,7 @@ for(let key in params)
case "flexHome":
{
let path = params[key];
if(flexjsUtils.isValidApacheFlexJSPath(path))
if(isValidApacheFlexJSPath(path))
{
flexHome = path;
}
Expand All @@ -131,9 +130,19 @@ for(let key in params)
scriptTarget = ts.ScriptTarget.ES5;
break;
}
case "ES6":
case "ES2015":
{
scriptTarget = ts.ScriptTarget.ES6;
scriptTarget = ts.ScriptTarget.ES2015;
break;
}
case "ES2016":
{
scriptTarget = ts.ScriptTarget.ES2016;
break;
}
case "ES2017":
{
scriptTarget = ts.ScriptTarget.ES2017;
break;
}
default:
Expand All @@ -152,7 +161,7 @@ for(let key in params)
case "exclude":
{
let value = params[key];
if(value instanceof String)
if(typeof value === "string")
{
excludedSymbols = [value];
}
Expand All @@ -165,7 +174,7 @@ for(let key in params)
case "include":
{
let value = params[key];
if(value instanceof String)
if(typeof value === "string")
{
includedSymbols = [value];
}
Expand Down Expand Up @@ -196,7 +205,7 @@ if(fileNames.length === 0)
}
if(flexHome === null)
{
flexHome = flexjsUtils.findFlexHome();
flexHome = findFlexHome();
}
if(outputDirectory === null)
{
Expand All @@ -216,7 +225,7 @@ if(swcOutputPath !== null)
}
else
{
if(debugLevel >= TS2ASParser.DebugLevel.INFO)
if(debugLevel >= DebugLevel.INFO)
{
console.info("Apache FlexJS: " + flexHome);
}
Expand Down Expand Up @@ -330,7 +339,7 @@ else
externsOutputPath = path.join(outputDirectory, "externs.js");
}
fs.writeFileSync(externsOutputPath, externsOutput);
if(debugLevel >= TS2ASParser.DebugLevel.INFO)
if(debugLevel >= DebugLevel.INFO)
{
console.info("Created JavaScript externs file: " + externsOutputPath);
}
Expand All @@ -356,7 +365,7 @@ if(swcOutputPath !== null)
}
else
{
if(debugLevel >= TS2ASParser.DebugLevel.INFO)
if(debugLevel >= DebugLevel.INFO)
{
console.info("Created SWC file for dependencies: " + depsSWCOutputPath);
}
Expand All @@ -383,7 +392,7 @@ if(swcOutputPath !== null)
console.error(compilerError);
console.error("Could not create SWC file. The generated ActionScript contains compile-time errors.");
}
else if(debugLevel >= TS2ASParser.DebugLevel.INFO)
else if(debugLevel >= DebugLevel.INFO)
{
console.info("Created SWC file: " + swcOutputPath);
}
Expand Down Expand Up @@ -417,7 +426,7 @@ function compileSWC(sourcePaths: string[], externsPath: string, swcPath: string)
{
let swcName = path.basename(swcPath, ".swc");
let externsName = swcName + ".js";
let compcPath = flexjsUtils.findBinCompc(flexHome);
let compcPath = findBinCompc(flexHome);
if(compcPath === null)
{
console.error("Could not find bin/compc in Apache FlexJS directory.");
Expand Down Expand Up @@ -448,7 +457,7 @@ function compileSWC(sourcePaths: string[], externsPath: string, swcPath: string)
//we need to use ./compc to avoid launching a different version of compc
//that might be added to the PATH environment variable.
let compcCommand = "." + path.sep + path.basename(compcPath);
if(debugLevel >= TS2ASParser.DebugLevel.INFO)
if(debugLevel >= DebugLevel.INFO)
{
console.info("Running: " + compcCommand + " " + compcArgs.join(" "));
}
Expand Down Expand Up @@ -500,7 +509,7 @@ function writeAS3File(symbol: as3.PackageLevelDefinition, sourcePaths: string[],
let outputDirPath = path.dirname(outputFilePath);
mkdirp.sync(outputDirPath);
fs.writeFileSync(outputFilePath, code);
if(debugLevel >= TS2ASParser.DebugLevel.INFO)
if(debugLevel >= DebugLevel.INFO)
{
console.info("Created ActionScript file: " + outputFilePath);
}
Expand Down Expand Up @@ -530,6 +539,6 @@ function printUsage()
console.info(" --moduleMetadata Include [JSModule] metadata for external modules.")
console.info(" -e SYMBOL, --exclude SYMBOL Specify the fully-qualified name of a symbol to exclude when emitting ActionScript.");
console.info(" -i SYMBOL, --include SYMBOL Specify the fully-qualified name of a symbol to include when emitting ActionScript. Excludes all other symbols.");
console.info(" -t VERSION, --target VERSION Specify ECMAScript target version for the TypeScript standard library: 'ES3', 'ES5' (default), or 'ES6'");
console.info(" -t VERSION, --target VERSION Specify ECMAScript target version for the TypeScript standard library: 'ES3', 'ES5' (default), 'ES2015', 'ES2016', or 'ES2017'");
console.info(" -v, --version Print the version of dts2as.");
}
9 changes: 4 additions & 5 deletions source/flexjs-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2015 Bowler Hat LLC
Copyright 2015-2017 Bowler Hat LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -13,11 +13,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/// <reference path="../typings/tsd.d.ts" />

import fs = require("fs");
import path = require("path");
import os = require("os");
import * as fs from "fs";
import * as path from "path";
import * as os from "os";

export function isValidApacheFlexJSPath(sdkPath: string)
{
Expand Down
11 changes: 4 additions & 7 deletions source/js-externs-emitter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2015 Bowler Hat LLC
Copyright 2015-2017 Bowler Hat LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -13,9 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/// <reference path="./as3.ts" />

import as3 = require("./as3");
import * as as3 from "./as3";

let NEW_LINE = "\n";

Expand All @@ -24,7 +23,7 @@ AS_TO_EXTERNS_TYPE_MAP[as3.BuiltIns[as3.BuiltIns.Number]] = "number";
AS_TO_EXTERNS_TYPE_MAP[as3.BuiltIns[as3.BuiltIns.Boolean]] = "boolean";
AS_TO_EXTERNS_TYPE_MAP[as3.BuiltIns[as3.BuiltIns.String]] = "string";

class JSExternsEmitter
export default class
{
constructor(types: as3.PackageLevelDefinition[])
{
Expand Down Expand Up @@ -442,6 +441,4 @@ class JSExternsEmitter
}
return null;
}
}

export = JSExternsEmitter;
}
Loading

0 comments on commit 3ce54b7

Please sign in to comment.