Skip to content

Commit 4819d68

Browse files
committed
Merge pull request #206 from nycdotnet/update-to-1.4.1
Update to 1.4.1
2 parents 78988fc + 5a88d53 commit 4819d68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+578
-3625
lines changed

Gruntfile.js

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ module.exports = function (grunt) {
1111
'.tscache/**/*',
1212
'!test/test.js',
1313
'!test/expected/**/*',
14-
'test/htmlOutDir/generated/test'
14+
'test/htmlOutDir/generated/test',
15+
'tscommand-*.txt'
1516
],
1617
testPost: [
1718
'src/a.js',
1819
'src/b.js',
1920
'src/c.js',
20-
'src/reference.js'
21+
'src/reference.js',
22+
'**/.baseDir.ts'
2123
]
2224
},
2325
jshint: {
@@ -239,6 +241,22 @@ module.exports = function (grunt) {
239241
module: 'amd'
240242
}
241243
},
244+
es6test: {
245+
test: true,
246+
src: 'test/es6/stringTemplate.ts',
247+
outDir: 'test/es6/es6',
248+
options: {
249+
target: 'es6'
250+
}
251+
},
252+
es6_to_es5test: {
253+
test: true,
254+
src: 'test/es6/stringTemplate.ts',
255+
outDir: 'test/es6/es5',
256+
options: {
257+
target: 'es5'
258+
}
259+
},
242260
warnbothcomments: {
243261
test: true,
244262
src: ['test/abtest/**/*.ts'],
@@ -353,6 +371,68 @@ module.exports = function (grunt) {
353371
failOnTypeErrors: false
354372
}
355373
},
374+
hasEmitIfTypeErrorAnd_noEmitOnError_IsFalse: {
375+
test: true,
376+
src: 'test/noEmitOnError/testNoEmitOnError.ts',
377+
out: 'test/noEmitOnError/testNoEmitOnError_false.js',
378+
options: {
379+
failOnTypeErrors: false,
380+
noEmitOnError: false,
381+
fast: 'never'
382+
}
383+
},
384+
doesNotHaveEmitIfTypeErrorAnd_noEmitOnError_IsTrue: {
385+
test: true,
386+
src: 'test/noEmitOnError/testNoEmitOnError.ts',
387+
out: 'test/noEmitOnError/testNoEmitOnError_true.js',
388+
options: {
389+
failOnTypeErrors: false,
390+
noEmitOnError: true,
391+
fast: 'never'
392+
}
393+
},
394+
notPreservedIf_preserveConstEnums_IsFalse: {
395+
test: true,
396+
src: 'test/preserveConstEnums/test_preserveConstEnums.ts',
397+
out: 'test/preserveConstEnums/test_preserveConstEnums_false.js',
398+
options: {
399+
preserveConstEnums: false,
400+
fast: 'never'
401+
}
402+
},
403+
preservedIf_preserveConstEnums_IsTrue: {
404+
test: true,
405+
src: 'test/preserveConstEnums/test_preserveConstEnums.ts',
406+
out: 'test/preserveConstEnums/test_preserveConstEnums_true.js',
407+
options: {
408+
preserveConstEnums: true,
409+
fast: 'never'
410+
}
411+
},
412+
emitIf_suppressImplicitAnyIndexError_IsTrue: {
413+
test: true,
414+
src: 'test/suppressImplicitAnyIndexErrors/test_suppressImplicitAnyIndexError.ts',
415+
out: 'test/suppressImplicitAnyIndexErrors/test_suppressImplicitAnyIndexError_true.js',
416+
options: {
417+
suppressImplicitAnyIndexErrors: true,
418+
noImplicitAny: true,
419+
failOnTypeErrors: true,
420+
noEmitOnError: true,
421+
fast: 'never'
422+
}
423+
},
424+
doNotEmitIf_suppressImplicitAnyIndexError_IsFalse: {
425+
test: true,
426+
src: 'test/suppressImplicitAnyIndexErrors/test_suppressImplicitAnyIndexError.ts',
427+
out: 'test/suppressImplicitAnyIndexErrors/test_suppressImplicitAnyIndexError_false.js',
428+
options: {
429+
suppressImplicitAnyIndexErrors: false,
430+
noImplicitAny: true,
431+
failOnTypeErrors: false,
432+
noEmitOnError: true,
433+
fast: 'never'
434+
}
435+
},
356436
fail: {
357437
fail: true, // a designed to fail target
358438
src: ['test/fail/**/*.ts'],

README.md

Lines changed: 85 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@ Grunt-ts supports most `tsc` switches. Click the link to cross-reference to the
5757
|--module KIND|[module](#module)|Specify module style for code generation|
5858
|--noImplicitAny|[noImplicitAny](#noimplicitany)|Warn on expressions and declarations with an implied `any` type.|
5959
|--noResolve|[noResolve](#noresolve)|Skip resolution and preprocessing (deprecated)|
60+
|--out FILE|[out](#out)|Concatenate and emit output to a single file.|
61+
|--outDir DIRECTORY|[outDir](#outdir)|Redirect output structure to the directory.|
62+
|--preserveConstEnums|[preserveConstEnums](#preserveconstenums)|Const enums will be kept as enums in the emitted JS.|
6063
|--removeComments|[removeComments](#removecomments)|Configures if comments should be included in the output|
6164
|--sourceMap|[sourceMap](#sourcemap)|Generates corresponding `.map` file|
6265
|--sourceRoot LOCATION|[sourceRoot](#sourceroot)|Specifies the location where debugger should locate TypeScript files instead of source locations.|
63-
|--target VERSION|[target](#target)|Specify ECMAScript target version: `'es3'` or `'es5'`|
64-
|--out FILE|[out](#out)|Concatenate and emit output to a single file.|
65-
|--outDir DIRECTORY|[outDir](#outdir)|Redirect output structure to the directory.|
66+
|--suppressImplicitAnyIndexErrors|[suppressImplicitAnyIndexErrors](#suppressimplicitanyindexerrors)|Specifies the location where debugger should locate TypeScript files instead of source locations.|
67+
|--target VERSION|[target](#target)|Specify ECMAScript target version: `'es3'`, `'es5'`, or `'es6'`|
68+
6669

6770
For file ordering, look at [JavaScript Generation](#javascript-generation).
6871

@@ -87,12 +90,14 @@ For file ordering, look at [JavaScript Generation](#javascript-generation).
8790
|[options](#grunt-ts-target-options)|target||
8891
|[out](#out)|target|`string` - instruct `tsc` to concatenate output to this file.|
8992
|[outDir](#outdir)|target|`string` - instruct `tsc` to emit JS to this directory.|
93+
|[preserveConstEnums](#preserveconstenums)|option|`true`, `false` (default) - If true, const enums will be kept as enums in the emitted JS.|
9094
|[reference](#reference)|target|`string` - tells grunt-ts which file to use for maintaining references|
9195
|[removeComments](#removecomments)|option|`true` (default), `false` - removes comments in emitted JS|
9296
|[sourceRoot](#sourceroot)|option|`string` - root for referencing TS files in `.js.map`|
9397
|[sourceMap](#sourcemap)|option|`true` (default), `false` - indicates if source maps should be generated (`.js.map`)|
98+
|[suppressImplicitAnyIndexErrors](#suppressimplicitanyindexerrors)|option|`false` (default), `true` - indicates if TypeScript should allow access to properties of an object by string indexer when `--noImplicitAny` is active, even if TypeScript doesn't know about them.|
9499
|[src](#src)|target|`string` or `string[]` - glob of TypeScript files to compile.|
95-
|[target](#target)|option|`'es5'` (default) or `'es3'` - targeted ECMAScript version|
100+
|[target](#target)|option|`'es5'` (default), `'es3'`, or `'es6'` - targeted ECMAScript version|
96101
|[verbose](#verbose)|option|`true`, `false` (default) - logs `tsc` command-line options to console|
97102
|[watch](#watch)|target|`string` - will watch for changes in the specified directory or below|
98103

@@ -528,6 +533,26 @@ grunt.initConfig({
528533
});
529534
````
530535

536+
#### noEmitOnError
537+
538+
````javascript
539+
true | false (default)
540+
````
541+
542+
Set to true to pass `--noEmitOnError` to the compiler. If set to true, TypeScript will not emit JavaScript if there is a type error. This flag does not affect the Grunt pipeline; to force the Grunt pipeline to continue (or halt) in the presence of TypeScript type errors, see [failOnTypeErrors](#failontypeerrors).
543+
544+
````javascript
545+
grunt.initConfig({
546+
ts: {
547+
default: {
548+
options: {
549+
noEmitOnError: true
550+
}
551+
}
552+
}
553+
});
554+
````
555+
531556
#### noImplicitAny
532557

533558
````javascript
@@ -548,6 +573,26 @@ grunt.initConfig({
548573
});
549574
````
550575

576+
#### preserveConstEnums
577+
578+
````javascript
579+
true | false (default)
580+
````
581+
582+
Set to true to pass `--preserveConstEnums` to the compiler. If set to true, TypeScript will emit code that allows other JavaScript code to use the enum. If false (the default), TypeScript will inline the enum values as magic numbers with a comment in the emitted JS.
583+
584+
````javascript
585+
grunt.initConfig({
586+
ts: {
587+
default: {
588+
options: {
589+
preserveConstEnums: true
590+
}
591+
}
592+
}
593+
});
594+
````
595+
551596
#### sourceMap
552597

553598
````javascript
@@ -584,13 +629,47 @@ grunt.initConfig({
584629
});
585630
````
586631

632+
633+
#### suppressImplicitAnyIndexErrors
634+
635+
````javascript
636+
true | false (default)
637+
````
638+
639+
Set to true to pass `--suppressImplicitAnyIndexErrors` to the compiler. If set to true, TypeScript will allow access to properties of an object by string indexer when `--noImplicitAny` is active, even if TypeScript doesn't know about them. This setting has no effect unless `--noImplicitAny` is active.
640+
641+
````javascript
642+
grunt.initConfig({
643+
ts: {
644+
default: {
645+
options: {
646+
suppressImplicitAnyIndexErrors: true,
647+
noImplicitAny: true
648+
}
649+
}
650+
}
651+
});
652+
````
653+
654+
For example, the following code would not compile with `--noImplicitAny` alone, but it would be legal with `--noImplicitAny` and `--suppressImplicitAnyIndexErrors` both enabled:
655+
656+
````typescript
657+
interface person {
658+
name: string;
659+
}
660+
661+
var p : person = { name: "Test" };
662+
p["age"] = 101; //property age does not exist on interface person.
663+
console.log(p["age"]);
664+
````
665+
587666
#### target
588667

589668
````javascript
590-
"es5" (default) | "es3"
669+
"es5" (default) | "es3" | "es6"
591670
````
592671

593-
Allows the developer to specify if they are targeting ECMAScript version 3 or 5. Only select ES3 if you are targeting old browsers (IE8 or below). The default for grunt-ts (es5) is different than the default for `tsc` (es3).
672+
Allows the developer to specify if they are targeting ECMAScript version 3, 5, or 6. Support for `es6` emit was added in TypeScript 1.4 and is listed as experimental. Only select ES3 if you are targeting old browsers (IE8 or below). The default for grunt-ts (es5) is different than the default for `tsc` (es3).
594673

595674
````javascript
596675
grunt.initConfig({

0 commit comments

Comments
 (0)