From e81585d9d35d6096d7cac66c8a3b3462667e220b Mon Sep 17 00:00:00 2001 From: barbatus Date: Tue, 16 Feb 2016 00:24:08 +0700 Subject: [PATCH] Add one more unit test and some minor fixes This is part of the effort to create an official TypeScript compiler: https://github.com/Urigo/angular2-meteor/issues/89 https://github.com/Urigo/angular2-meteor/issues/90 https://github.com/Urigo/angular2-meteor/issues/102 --- index.js | 8 +++++--- options.js | 4 ++-- package.json | 2 +- tests/ts.spec.js | 11 +++++++++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 2c2a773..3ca5420 100644 --- a/index.js +++ b/index.js @@ -45,8 +45,8 @@ var validOptions = { "moduleName": "String", "typings": "Array" }; -var validOptionsMsg = "Valid options are" + - "compilerOptions, filePath, moduleName, and typings"; +var validOptionsMsg = "Valid options are " + + "compilerOptions, filePath, moduleName, and typings."; function checkType(option, optionName) { if (! option) return true; @@ -61,7 +61,7 @@ function validateAndConvertOptions(options) { for (var option in options) { if (options.hasOwnProperty(option)) { if (validOptions[option] === undefined) { - throw new Error("Unknown option: " + option + "." + + throw new Error("Unknown option: " + option + ".\n" + validOptionsMsg); } @@ -79,6 +79,8 @@ function validateAndConvertOptions(options) { } } +exports.validateAndConvertOptions = validateAndConvertOptions; + exports.getDefaultOptions = function getDefaultOptions() { return { compilerOptions: getDefaultCompilerOptions() diff --git a/options.js b/options.js index 3f41f0d..15141af 100644 --- a/options.js +++ b/options.js @@ -45,8 +45,8 @@ exports.presetCompilerOptions = presetCompilerOptions; // Default compiler options. function getDefaultCompilerOptions() { return { - module : ts.ModuleKind.CommonJS, - target: ts.ScriptTarget.ES3, + module : "commonjs", + target: "ES3", sourceMap: true, noResolve: false, diagnostics: true, diff --git a/package.json b/package.json index 0343f5c..6d1c6bc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "meteor-typescript", "author": "@barbatus", - "version": "0.5.5", + "version": "0.5.7", "license": "MIT", "description": "TypeScript wrapper package for use with Meteor", "keywords": [ diff --git a/tests/ts.spec.js b/tests/ts.spec.js index 2c183ac..d95c1c5 100644 --- a/tests/ts.spec.js +++ b/tests/ts.spec.js @@ -58,6 +58,17 @@ describe("meteor-typescript -> ", function() { }; expect(test).toThrow(); }); + + it("should validate options", function() { + var test = function() { + meteorTS.validateAndConvertOptions({ + wrong: true + }); + }; + + expect(test).toThrow(new Error("Unknown option: wrong.\n" + + "Valid options are compilerOptions, filePath, moduleName, and typings.")); + }); }); describe("testing diagnostics and typings -> ", function() {