Skip to content

Commit 6ce0883

Browse files
committed
Merge pull request #320 from TypeStrong/update-to-ts-1.7.3
Update to TypeScript 1.7.3
2 parents 1bbe242 + 05f353e commit 6ce0883

31 files changed

+804
-314
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
## Next
44

5+
## v5.3.0-beta.6 (2016-01-15)
6+
* FIX: Will now resolve templates prior to updating the globs in a tsconfig.json file (#303) - thanks for the report @nsgundy.
7+
8+
## v5.3.0-beta.5 (2016-01-14)
9+
* FIX: Will now provide a warning when a grunt-ts task-level keyword is used as a target name (#319) - thanks for the report @jounii.
10+
11+
## v5.3.0-beta.4 (2016-01-14)
12+
* FIX: Transformed HTML files will be automatically added to the compilation context if they match the glob (#255).
13+
* FIX: resolved issue in v5.3.0-beta.3 - will now error again if `html` is specified without an `src` or a glob.
14+
15+
## v5.3.0-beta.3 (2015-12-26)
16+
* FIX: Use of `outDir` in the Gruntfile now works when otherwise getting the configuration from tsconfig.json. (Thanks, @gilamran (#312)).
17+
* NOTE: No longer warns when `html` is used without a source. This needs to wait on #255.
18+
* FIX: Certain conditions (such as the specified tsconfig.json not found or VS project resolution errors) caused grunt-ts to hard-quit during options resolution. These are now properly surfaced as errors, and the main quit path will be followed.
19+
20+
## v5.3.0-beta.2 (2015-12-06)
21+
* FEAT: Updated to TypeScript 1.7 and revised all integration tests to account for its behavior (generally, the change to how `removeComments` works).
22+
* FEAT: Added support for `--noLib`, `--emitBOM`, `--locale`, `--suppressExcessPropertyErrors`, `--stripInternal`, and `--allowSyntheticDefaultImports`.
23+
* FEAT: Added support for `es6` and `es2015` as module options.
24+
525
## v5.3.0-beta.1 (2015-12-06)
626
* FIX: Improved detection of if newLine parameter is redundant for TSC. This should make the functionality work more consistently if `grunt.util.linefeed` is used. Thanks to @Maks3w for the report.
727

Gruntfile.js

Lines changed: 183 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports = function (grunt) {
2121
'test/htmlExternal/html.external.html.ts',
2222
'tscommand-*.txt',
2323
'!test/commandLineAssertions.js',
24+
'!test/optionsResolverTests.js',
2425
'test/**/*.orig'
2526
],
2627
testPost: [
@@ -246,7 +247,8 @@ module.exports = function (grunt) {
246247
'test/files_ObjectFormat/b.js': ['test/multifile/b/**/*.ts', 'test/simple/ts/**/*.ts']
247248
},
248249
options: {
249-
fast: 'never'
250+
fast: 'never',
251+
comments: true
250252
}
251253
},
252254
abtest: {
@@ -414,7 +416,7 @@ module.exports = function (grunt) {
414416
options: {
415417
htmlModuleTemplate: '<%= filename %>_<%= ext %>_module',
416418
htmlVarTemplate: '<%= filename %>_<%= ext %>_variable',
417-
comments: false
419+
comments: true
418420
},
419421
},
420422
htmlWithHtmlOutDirTest: {
@@ -491,15 +493,17 @@ module.exports = function (grunt) {
491493
outDir: 'test/transform/js',
492494
options: {
493495
fast: 'never',
494-
module: 'commonjs'
496+
module: 'commonjs',
497+
comments: true
495498
}
496499
},
497500
refTransform: {
498501
test: true,
499502
src: ['test/references-transform/**/*.ts','test/references*.d.ts'],
500503
options: {
501-
fast: 'always',
502-
noImplicitAny: true
504+
fast: 'never',
505+
noImplicitAny: true,
506+
comments: true
503507
}
504508
},
505509
customcompiler: {
@@ -846,6 +850,60 @@ module.exports = function (grunt) {
846850
sourceRoot: 'test/sourceRoot with spaces',
847851
mapRoot: 'test/mapRoot with spaces'
848852
}
853+
},
854+
test_noLib: {
855+
test: true,
856+
testExecute: commandLineAssertions.test_noLib,
857+
src: 'test/simple/ts/zoo.ts',
858+
options: {
859+
noLib: true
860+
}
861+
},
862+
test_emitBOM: {
863+
test: true,
864+
testExecute: commandLineAssertions.test_emitBOM,
865+
src: 'test/simple/ts/zoo.ts',
866+
options: {
867+
emitBOM: true
868+
}
869+
},
870+
test_locale: {
871+
test: true,
872+
testExecute: commandLineAssertions.test_locale,
873+
src: 'test/simple/ts/zoo.ts',
874+
options: {
875+
locale: 'ja-jp'
876+
}
877+
},
878+
test_suppressExcessPropertyErrors: {
879+
test: true,
880+
testExecute: commandLineAssertions.test_suppressExcessPropertyErrors,
881+
src: 'test/simple/ts/zoo.ts',
882+
options: {
883+
suppressExcessPropertyErrors: true
884+
}
885+
},
886+
test_stripInternal: {
887+
test: true,
888+
testExecute: commandLineAssertions.test_stripInternal,
889+
src: 'test/simple/ts/zoo.ts',
890+
options: {
891+
stripInternal: true
892+
}
893+
},
894+
test_allowSyntheticDefaultImports: {
895+
test: true,
896+
testExecute: commandLineAssertions.test_allowSyntheticDefaultImports,
897+
src: 'test/simple/ts/zoo.ts',
898+
options: {
899+
allowSyntheticDefaultImports: true
900+
}
901+
},
902+
test_htmlTemplateGlob: {
903+
test: false, // called manually by test_htmlTemplateResultAddedToGlobs.
904+
files: [{ src: ['test/htmlTemplateGlob/**/t*.ts']},
905+
{ src: ['test/htmlTemplateGlob/**/o*.ts'] }],
906+
html: ['test/htmlTemplateGlob/**/*.html']
849907
}
850908
}
851909
});
@@ -900,21 +958,28 @@ module.exports = function (grunt) {
900958
memo.push('ts:' + name);
901959
}
902960
return memo;
903-
}, []));
961+
}, ['test_htmlTemplateResultAddedToGlobs']));
904962

905963
(function() {
906964
// Collect fail tasks
907965
var grunt_ts_total_failures = 0,
908966
failTasks = grunt.util._.reduce(grunt.config.get('ts'), function (memo, task, name) {
909-
if (task.fail) {
910-
memo.push('ts:' + name);
911-
}
912-
return memo;
913-
}, []);
967+
if (task.fail) {
968+
memo.push('ts:' + name);
969+
}
970+
return memo;
971+
}, []),
972+
fastIntegrationTests = grunt.util._.reduce(grunt.config.get('ts'), function (memo, task, name) {
973+
if (task.test && task.testExecute) {
974+
memo.push('ts:' + name);
975+
}
976+
return memo;
977+
}, []);
914978
grunt.registerTask('test_fail', failTasks);
979+
grunt.registerTask('test_fastIntegration', fastIntegrationTests);
915980
grunt.event.on('grunt-ts.failure', function() {
916-
grunt_ts_total_failures += 1;
917-
});
981+
grunt_ts_total_failures += 1;
982+
});
918983
grunt.registerTask('validate_failure_count', 'Counts failure events emitted by grunt-ts', function() {
919984
console.log('Expected ' + failTasks.length + ' task failures, got ' +
920985
grunt_ts_total_failures + ' failures.');
@@ -953,6 +1018,64 @@ module.exports = function (grunt) {
9531018
grunt.registerTask('release', ['build', 'test', 'report-time-elapsed']);
9541019
grunt.registerTask('default', ['release']);
9551020

1021+
(function(){
1022+
var test_htmlTemplateResultAddedToGlobs_shouldExist = [
1023+
'test/htmlTemplateGlob/test.html.ts',
1024+
'test/htmlTemplateGlob/test.html.js',
1025+
'test/htmlTemplateGlob/test.html.js.map',
1026+
'test/htmlTemplateGlob/doNotTranspile.html.ts'
1027+
];
1028+
var test_htmlTemplateResultAddedToGlobs_shouldNotExist = [
1029+
'test/htmlTemplateGlob/doNotTranspile.html.js',
1030+
'test/htmlTemplateGlob/doNotTranspile.html.js.map'
1031+
];
1032+
1033+
grunt.registerTask('test_htmlTemplateResultAddedToGlobs',
1034+
'integration test to prove that new TS files created by HTML evaluation are included on the' +
1035+
'first run.', function() {
1036+
1037+
[test_htmlTemplateResultAddedToGlobs_shouldExist,
1038+
test_htmlTemplateResultAddedToGlobs_shouldNotExist].forEach(
1039+
function (array) {
1040+
array.forEach(function (fileName) {
1041+
if (grunt.file.exists(fileName)) {
1042+
grunt.file.delete(fileName);
1043+
}
1044+
});
1045+
}
1046+
);
1047+
1048+
grunt.task.run('ts:test_htmlTemplateGlob');
1049+
grunt.task.run('test_htmlTemplateResultAddedToGlobsAssert');
1050+
});
1051+
1052+
grunt.registerTask('test_htmlTemplateResultAddedToGlobsAssert',
1053+
'integration test to prove that new TS files created by HTML evaluation are included on the' +
1054+
'first run.', function() {
1055+
var validatedFileCount = 0, result = true;
1056+
test_htmlTemplateResultAddedToGlobs_shouldExist.forEach(
1057+
function (fileName) {
1058+
if (!grunt.file.exists(fileName)) {
1059+
console.log('Expected file "' + fileName + '" to exist.');
1060+
result = false;
1061+
} else {
1062+
validatedFileCount += 1;
1063+
}
1064+
});
1065+
test_htmlTemplateResultAddedToGlobs_shouldNotExist.forEach(
1066+
function (fileName) {
1067+
if (grunt.file.exists(fileName)) {
1068+
console.log('Expected file "' + fileName + '" to not exist.');
1069+
result = false;
1070+
} else {
1071+
validatedFileCount += 1;
1072+
}
1073+
});
1074+
return result && (validatedFileCount === 6);
1075+
});
1076+
}());
1077+
1078+
9561079
//////////////////////////////////////////////
9571080
// Dev
9581081
//
@@ -966,53 +1089,62 @@ module.exports = function (grunt) {
9661089

9671090
grunt.registerTask('dev', ['run', 'watch']);
9681091

969-
grunt.registerTask('run', function () {
1092+
function taskToBuildGruntTsAndThenRunOtherTasks(tasksToRun) {
1093+
return function() {
9701094

971-
// Clear the console and move to 0 0
972-
// http://stackoverflow.com/a/14976765/390330
973-
console.log('\u001b[2J\u001b[0;0H');
974-
console.log('>>>>>>>>>>> Cleared console >>>>>>>>>>> \n\n'.grey);
1095+
// Clear the console and move to 0 0
1096+
// http://stackoverflow.com/a/14976765/390330
1097+
console.log('\u001b[2J\u001b[0;0H');
1098+
console.log('>>>>>>>>>>> Cleared console >>>>>>>>>>> \n\n'.grey);
9751099

976-
var done = this.async();
1100+
var done = this.async();
1101+
1102+
// Using a simple chain of ts:internal followed by ts:yourtest would not have run the updated grunt-ts
1103+
// We are spawn to ensure that `ts:` is reloaded after compile
1104+
function runTask(taskName, callback) {
1105+
grunt.util.spawn({
1106+
cmd: 'grunt',
1107+
args: [taskName]
1108+
}, function (err, output) {
1109+
if (err) {
1110+
console.log(output.stderr || output.stdout);
1111+
done(err);
1112+
}
1113+
else {
1114+
console.log(output.stdout);
1115+
console.log('\n'); // looks better
1116+
callback();
1117+
}
1118+
});
1119+
}
1120+
1121+
// Add build task
1122+
tasksToRun.unshift('ts-internal:build');
9771123

978-
// Using a simple chain of ts:internal followed by ts:yourtest would not have run the updated grunt-ts
979-
// We are spawn to ensure that `ts:` is reloaded after compile
980-
function runTask(taskName, callback) {
981-
grunt.util.spawn({
982-
cmd: 'grunt',
983-
args: [taskName]
984-
}, function (err, output) {
985-
if (err) {
986-
console.log(output.stderr || output.stdout);
987-
done(err);
1124+
// Now execute
1125+
var currentIndex = 0;
1126+
function getNextTaskFunction() {
1127+
currentIndex++;
1128+
if (currentIndex === tasksToRun.length) {
1129+
return done;
9881130
}
9891131
else {
990-
console.log(output.stdout);
991-
console.log('\n'); // looks better
992-
callback();
1132+
return function () {
1133+
runTask(tasksToRun[currentIndex], getNextTaskFunction());
1134+
};
9931135
}
994-
});
995-
}
1136+
}
1137+
runTask(tasksToRun[0], getNextTaskFunction());
1138+
};
1139+
}
9961140

997-
// Add build task
998-
tasksToTest.unshift('ts-internal:build');
9991141

1000-
// Now execute
1001-
var currentIndex = 0;
1002-
function getNextTaskFunction() {
1003-
currentIndex++;
1004-
if (currentIndex === tasksToTest.length) {
1005-
return done;
1006-
}
1007-
else {
1008-
return function () {
1009-
runTask(tasksToTest[currentIndex], getNextTaskFunction());
1010-
};
1011-
}
1012-
}
1013-
runTask(tasksToTest[0], getNextTaskFunction());
1142+
grunt.registerTask('testfast', taskToBuildGruntTsAndThenRunOtherTasks(
1143+
['ts-internal:test', 'stageFiles','test_fastIntegration', 'nodeunit:fast']
1144+
));
10141145

1015-
});
1146+
1147+
grunt.registerTask('run', taskToBuildGruntTsAndThenRunOtherTasks(tasksToTest));
10161148

10171149
grunt.registerTask('report-time-elapsed','Reports the time elapsed since gruntStartedTimestamp', function() {
10181150
var seconds = ((new Date().getTime()) - gruntStartedTimestamp) / 1000;

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,10 +829,10 @@ grunt.initConfig({
829829
#### module
830830

831831
````javascript
832-
"amd" (default) | "commonjs" | "system" | "umd" | ""
832+
"amd" (default) | "commonjs" | "system" | "umd" | "es6" | "es2015" | ""
833833
````
834834

835-
Specifies if TypeScript should emit AMD, CommonJS, SystemJS, or UMD-style external modules. Has no effect if internal modules are used. Note - this should not be used in combination with `out` because the TypeScript compiler does not support concatenation of external modules; consider using a module bundler like WebPack, Browserify, or Require's r.js to concatenate external modules.
835+
Specifies if TypeScript should emit AMD, CommonJS, SystemJS, "ES6", or UMD-style external modules. Has no effect if internal modules are used. Note - this should not be used in combination with `out` [prior to TypeScript 1.8](https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#option-to-concatenate-amd-and-system-modules-into-a-single-output-file) because the TypeScript compiler does not support concatenation of external modules; consider using a module bundler like WebPack, Browserify, or Require's r.js to concatenate external modules.
836836

837837
````javascript
838838
grunt.initConfig({

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "basarat",
33
"name": "grunt-ts",
44
"description": "Compile and manage your TypeScript project",
5-
"version": "5.3.0-beta.1",
5+
"version": "5.3.0-beta.6",
66
"homepage": "https://github.com/grunt-ts/grunt-ts",
77
"repository": {
88
"type": "git",
@@ -45,7 +45,7 @@
4545
"ncp": "0.5.1",
4646
"rimraf": "2.2.6",
4747
"strip-bom": "^2.0.0",
48-
"typescript": "1.6.2",
48+
"typescript": "1.7.3",
4949
"underscore": "1.5.1",
5050
"underscore.string": "2.3.3"
5151
},

0 commit comments

Comments
 (0)