meteor-typescript
Advanced tools
Comparing version
13
index.js
@@ -39,2 +39,6 @@ "use strict"; | ||
function isES6Target(target) { | ||
return /es6/i.test(target) || /es2015/i.test(target); | ||
}; | ||
function defaultCompilerOptions(arch, opt) { | ||
@@ -47,3 +51,3 @@ var defOpt = getDefaultCompilerOptions(arch); | ||
// if target: "es6" and lib: ["es5"], | ||
// if won't compile properly. | ||
// it won't compile properly. | ||
if (resOpt.target) { | ||
@@ -54,2 +58,9 @@ resOpt.lib.push(resOpt.target); | ||
// Impose use strict for ES6 target. | ||
if (opt && opt.noImplicitUseStrict !== undefined) { | ||
if (isES6Target(resOpt.target)) { | ||
resOpt.noImplicitUseStrict = false; | ||
} | ||
} | ||
return resOpt; | ||
@@ -56,0 +67,0 @@ } |
@@ -59,2 +59,3 @@ "use strict"; | ||
diagnostics: true, | ||
noEmitHelpers: true, | ||
// Always emit class metadata, | ||
@@ -61,0 +62,0 @@ // especially useful for Angular2. |
{ | ||
"name": "meteor-typescript", | ||
"author": "@barbatus", | ||
"version": "0.7.1", | ||
"version": "0.7.2-beta.1", | ||
"license": "MIT", | ||
@@ -33,3 +33,3 @@ "description": "TypeScript wrapper package for use with Meteor", | ||
"random-js": "^1.0.3", | ||
"typescript": "2.0.0", | ||
"typescript": "2.1.1", | ||
"underscore": "^1.8.3" | ||
@@ -36,0 +36,0 @@ }, |
@@ -132,2 +132,26 @@ var ts = require("typescript"); | ||
}); | ||
it("should compile target ES6", function() { | ||
var code = "async function service() { return await Promise.resolve(1); }"; | ||
var result = meteorTS.compile(code, getOptions({ | ||
compilerOptions: { | ||
target: "ES5" | ||
} | ||
})); | ||
console.log(result.code); | ||
// Async resolved through the generator in ES6 | ||
//expect(result.code).toContain("function*"); | ||
}); | ||
it("impose 'use strict' for ES6", function() { | ||
var result = meteorTS.compile(testCodeLine, getOptions({ | ||
compilerOptions: { | ||
target: "ES6" | ||
} | ||
})); | ||
expect(result.code).toContain("use strict"); | ||
}); | ||
}); | ||
@@ -424,17 +448,2 @@ | ||
}); | ||
it("should compile ES6", function() { | ||
var options = { | ||
compilerOptions: { | ||
target: 'ES6' | ||
} | ||
}; | ||
var code = "for (let target of ['es6']) {}" | ||
var build = new TSBuild(["foo18.ts"], function(filePath) { | ||
if (filePath === "foo18.ts") return code; | ||
}, getOptions(options)); | ||
var result = build.emit("foo18.ts"); | ||
expect(result.diagnostics.semanticErrors.length).toEqual(0); | ||
}); | ||
}); | ||
@@ -441,0 +450,0 @@ |
51693
1%1466
1.1%+ Added
- Removed
Updated