You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -51,15 +51,22 @@ A more extensive sample `Gruntfile.js` is available [here](https://github.com/Ty
51
51
52
52
## Support for tsc Switches
53
53
54
-
Grunt-ts supports most `tsc` switches. Click the link to cross-reference to the grunt-ts option.
54
+
Grunt-ts provides explicit support for most `tsc` switches. Any arbitrary switches can be passed to `tsc` via the [additionalFlags](#additionalflags) feature.
55
55
56
-
|`tsc` switch|grunt-ts analogue|description|
56
+
|`tsc` switch|name in grunt-ts|description|
57
57
|:----:|:----:|:-----|
58
-
| --declaration|[declaration](#declaration)|Generates a `.d.ts` definitions file for compiled TypeScript files|
58
+
|--declaration|[declaration](#declaration)|Generates a `.d.ts` definitions file for compiled TypeScript files|
59
+
|--emitDecoratorMetadata|[emitDecoratorMetadata](#emitdecoratormetadata)|Emit design-type metadata for decorated declarations in source|
60
+
|--inlineSourceMap|[inlineSourceMap](#inlinesourcemap)|Emit a single file that includes source maps instead of emitting a separate `.js.map` file.|
61
+
|--inlineSources|[inlineSources](#inlinesources)|Emit the TypeScript source alongside the sourcemaps within a single file; requires `--inlineSourceMap` to be set.|
62
+
|--isolatedModules|[isolatedModules](#isolatedmodules)|Ensures that the output is safe to only emit single files by making cases that break single-file transpilation an error|
59
63
|--mapRoot LOCATION|[mapRoot](#maproot)|Specifies the location where debugger should locate map files instead of generated locations.|
60
64
|--module KIND|[module](#module)|Specify module style for code generation|
65
+
|--newLine|[newLine](#newline)|Explicitly specify newline character (`CRLF` or `LF`); if omitted, uses OS default.|
66
+
|--noEmit|[noEmit](#noemit)|Check, but do not emit JS, even in the absence of errors.|
67
+
|--noEmitHelpers|[noEmitHelpers](#noemithelpers)|Do not generate custom helper functions like `__extends` in compiled output.|
61
68
|--noImplicitAny|[noImplicitAny](#noimplicitany)|Warn on expressions and declarations with an implied `any` type.|
62
-
|--noResolve|[noResolve](#noresolve)|Skip resolution and preprocessing (deprecated)|
69
+
|--noResolve|[noResolve](#noresolve)|Do not add triple-slash references or module import targets to the compilation context.|
63
70
|--out FILE|[out](#out)|Concatenate and emit output to a single file.|
64
71
|--outDir DIRECTORY|[outDir](#outdir)|Redirect output structure to the directory.|
65
72
|--preserveConstEnums|[preserveConstEnums](#preserveconstenums)|Const enums will be kept as enums in the emitted JS.|
@@ -76,6 +83,7 @@ For file ordering, look at [JavaScript Generation](#javascript-generation).
76
83
77
84
|property|where to define|description|
78
85
|:----|:----|:-----|
86
+
|[additionalFlags](#additionalflags)|option|`string` - allows passing arbitrary strings to the compiler. This is intended to enable compatibility with features not supported directly by grunt-ts.|
79
87
|[comments](#comments)|option|`true`, `false` (default) - include comments in emitted JS.|
|[compiler](#compiler)|option|`string` - path to custom compiler|
@@ -87,9 +95,14 @@ For file ordering, look at [JavaScript Generation](#javascript-generation).
87
95
|[html](#html)|target|`string` or `string[]` - glob to HTML templates|
88
96
|[htmlModuleTemplate](#htmlmoduletemplate)|option|`string` - HTML template namespace|
89
97
|[htmlVarTemplate](#htmlvartemplate)|option|`string` - HTML property name|
98
+
|[inlineSourceMap](#inlinesourcemap)|option|`true`, `false` (default) Emit a single file that includes source maps instead of emitting a separate `.js.map` file; If enabled, will automatically enable `sourceMap`.|
99
+
|[inlineSources](#inlinesources)|option|`true`, `false` (default) Emit the TypeScript source alongside the sourcemaps within a single file; If enabled, will automatically enable `inlineSourceMap` and `sourceMap`.|
100
+
|[isolatedModules](#isolatedmodules)|option|`true`, `false` (default) Ensures that the output is safe to only emit single files by making cases that break single-file transpilation an error.|
90
101
|[mapRoot](#maproot)|option|`string` - root for referencing `.js.map` files in JS|
91
102
|[module](#module)|option|default to be nothing, If you want to set it you set it to either `'amd'` or `'commonjs'`|
103
+
|[newLine](#newline)|option|`CRLF`, `LF`, `` (default) - If passed with a value, TypeScript will use the specified line endings. Also affects grunt-ts transforms.|
92
104
|[noEmit](#noemit)|option|`true`, `false` (default) - If passed as `true`, TypeScript will not emit even if it compiles cleanly|
105
+
|[noEmitHelpers](#noemithelpers)|option|`true`, `false` (default) - If passed as `true`, TypeScript will not generate custom helper functions like `__extends` in compiled output|
93
106
|[noImplicitAny](#noimplicitany)|option|`true`, `false` (default) - enable for stricter type checking|
94
107
|[noResolve](#noresolve)|option|`true`, `false` (default) - for deprecated version of TypeScript|
95
108
|[options](#grunt-ts-target-options)|target||
@@ -225,6 +238,10 @@ Specify this option if you do not want the lib.d.ts to be loaded by the TypeScri
225
238
226
239
Passes the --out switch to `tsc`. This will cause the emitted JavaScript to be concatenated to a single file if your code allows for that.
227
240
241
+
Note - the sequence of concatenation when using namespaces (formerly called internal modules) is usually significant. You can assist TypeScript to order the emitted JavaScript correctly by changing the sequence in which files appear in your glob. For example, if you have `a.ts`, `b.ts`, and `c.ts` and use the glob `'*.ts`, the default would be for TypeScript to concatenate the files in alphabetical order. If you needed the content from `b.ts` to appear first, and then the rest in alphabetical order, you could specify the glob like this: `['b.ts','*.ts']`.
242
+
243
+
Note - the `out` feature should not be used in combination with `module` 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.
244
+
228
245
````javascript
229
246
grunt.initConfig({
230
247
ts: {
@@ -352,6 +369,22 @@ grunt.initConfig({
352
369
353
370
### grunt-ts target options
354
371
372
+
#### additionalFlags
373
+
374
+
Allows passing arbitrary strings to the compiler. This is intended to enable compatibility with features not supported directly by grunt-ts. The parameters will be passed exactly as-is with a space separating them from the previous switches. It is possible to pass more than one switch with `additionalFlags` by separating them with spaces.
@@ -408,15 +441,6 @@ The `package.json` would look something like this for a legacy project:
408
441
Note: It is safest to pin the exact TypeScript version (do not use `~` or `>`).
409
442
410
443
411
-
412
-
#### noResolve
413
-
414
-
````javascript
415
-
true|false (default)
416
-
````
417
-
418
-
*Deprecated:* Grunt-ts supports passing this parameter to legacy versions of `tsc`. It will pass `--noResolve` on the command line.
419
-
420
444
#### comments
421
445
422
446
````javascript
@@ -435,37 +459,37 @@ grunt.initConfig({
435
459
});
436
460
````
437
461
438
-
#### removeComments
462
+
#### declaration
439
463
440
464
````javascript
441
-
true(default)|false
465
+
true|false (default)
442
466
````
443
467
444
-
Removes comments in the emitted JavaScript if set to `true`. Preserves comments if set to `false`. Note that if `comments` and `removeComments` are both used, the value of `removeComments` will win; regardless, please don't do this as it is just confusing to everyone.
468
+
Generates corresponding .d.ts file(s) for compiled TypeScript files.
445
469
446
470
````javascript
447
471
grunt.initConfig({
448
472
ts: {
449
473
options: {
450
-
removeComments:false//preserves comments in output.
474
+
declaration:true
451
475
}
452
476
}
453
477
});
454
478
````
455
479
456
-
#### declaration
480
+
#### emitDecoratorMetadata
457
481
458
482
````javascript
459
483
true|false (default)
460
484
````
461
485
462
-
Generates corresponding .d.ts file(s) for compiled TypeScript files.
486
+
Emit design-type metadata for decorated declarations in source. This is only available in TypeScript 1.5 and higher.
463
487
464
488
````javascript
465
489
grunt.initConfig({
466
490
ts: {
467
491
options: {
468
-
declaration:true
492
+
emitDecoratorMetadata:true
469
493
}
470
494
}
471
495
});
@@ -554,7 +578,7 @@ grunt.initConfig({
554
578
555
579
#### htmlOutputTemplate
556
580
557
-
Grunt-ts supports compilation of `.html` file content to TypeScript variables which is explained in detail [here](/docs/html2ts.md). The `htmlOutputTemplate` target property allows the developer to override the internally defined output template to a custom one, useful if one would like to define the HTML output as an external modules, for example.
581
+
Grunt-ts supports compilation of `.html` file content to TypeScript variables which is explained in detail [here](/docs/html2ts.md). The `htmlOutputTemplate` target property allows the developer to override the internally defined output template to a custom one, useful if one would like to define the HTML output as an external modules, for example.
558
582
Three variables can be used in this template, namely:
559
583
560
584
@@ -582,6 +606,67 @@ grunt.initConfig({
582
606
});
583
607
````
584
608
609
+
#### inlineSourceMap
610
+
611
+
````javascript
612
+
true|false (default)
613
+
````
614
+
615
+
When true, TypeScript will emit source maps inline at the bottom of each JS file, instead of emitting a separate `.js.map` file. Note: specifying this option will automatically enable `sourceMap`.
616
+
617
+
````javascript
618
+
grunt.initConfig({
619
+
ts: {
620
+
default: {
621
+
options: {
622
+
inlineSourceMap:true
623
+
}
624
+
}
625
+
}
626
+
});
627
+
````
628
+
629
+
#### inlineSources
630
+
631
+
````javascript
632
+
true|false (default)
633
+
````
634
+
635
+
When true, TypeScript will emit the TypeScript sources at the bottom of each JS file along with an inline sourcemap, instead of emitting source maps that reference an external `.ts` file. Note: specifying this option will automatically enable both `sourceMap` and `inlineSourceMap`.
636
+
637
+
````javascript
638
+
grunt.initConfig({
639
+
ts: {
640
+
default: {
641
+
options: {
642
+
inlineSources:true
643
+
}
644
+
}
645
+
}
646
+
});
647
+
````
648
+
649
+
#### isolatedModules
650
+
651
+
````javascript
652
+
true|false (default)
653
+
````
654
+
655
+
When true, makes scenarios that break single-file transpilation into an error. See https://github.com/Microsoft/TypeScript/issues/2499 for more details. If you are using TypeScript 1.5, and fast compilation, it is ideal to use this to take advantage of future compilation optimizations.
656
+
657
+
````javascript
658
+
grunt.initConfig({
659
+
ts: {
660
+
default: {
661
+
options: {
662
+
isolatedModules:true
663
+
}
664
+
}
665
+
}
666
+
});
667
+
````
668
+
669
+
585
670
#### mapRoot
586
671
587
672
Specifies the root for where `.js.map` sourcemap files should be referenced. This is useful if you intend to move your `.js.map` files to a different location. Leave this blank or omit entirely if the `.js.map` files will be deployed to the same folder as the corresponding `.js` files. See also [sourceRoot](#sourceroot).
@@ -601,6 +686,26 @@ grunt.initConfig({
601
686
602
687
#### module
603
688
689
+
````javascript
690
+
"amd" (default) |"commonjs"|"system"|"umd"|""
691
+
````
692
+
693
+
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.
694
+
695
+
````javascript
696
+
grunt.initConfig({
697
+
ts: {
698
+
default: {
699
+
options: {
700
+
module:"amd"
701
+
}
702
+
}
703
+
}
704
+
});
705
+
````
706
+
707
+
#### module
708
+
604
709
````javascript
605
710
"amd" (default) |"commonjs"|""
606
711
````
@@ -619,6 +724,66 @@ grunt.initConfig({
619
724
});
620
725
````
621
726
727
+
#### newLine
728
+
729
+
````javascript
730
+
"CRLF"|"LF"|"" (default)
731
+
````
732
+
733
+
Will force TypeScript to use the specified newline sequence. Grunt-ts will also use this newline sequence for transforms. If not specified, TypeScript and grunt-ts use the OS default.
734
+
735
+
````javascript
736
+
grunt.initConfig({
737
+
ts: {
738
+
default: {
739
+
options: {
740
+
newLine:"CRLF"
741
+
}
742
+
}
743
+
}
744
+
});
745
+
````
746
+
747
+
#### noEmit
748
+
749
+
````javascript
750
+
true|false (default)
751
+
````
752
+
753
+
Set to true to pass `--noEmit` to the compiler. If set to true, TypeScript will not emit JavaScript regardless of if the compile succeeds or fails.
754
+
755
+
````javascript
756
+
grunt.initConfig({
757
+
ts: {
758
+
default: {
759
+
options: {
760
+
noEmit:true
761
+
}
762
+
}
763
+
}
764
+
});
765
+
````
766
+
767
+
#### noEmitHelpers
768
+
769
+
````javascript
770
+
true|false (default)
771
+
````
772
+
773
+
Set to true to pass `--noEmitHelpers` to the compiler. If set to true, TypeScript will not emit JavaScript helper functions such as `__extends`. This is for very advanced users who wish to provide their own implementation of the TypeScript runtime helper functions.
774
+
775
+
````javascript
776
+
grunt.initConfig({
777
+
ts: {
778
+
default: {
779
+
options: {
780
+
noEmitHelpers:true
781
+
}
782
+
}
783
+
}
784
+
});
785
+
````
786
+
622
787
#### noEmitOnError
623
788
624
789
````javascript
@@ -659,6 +824,24 @@ grunt.initConfig({
659
824
});
660
825
````
661
826
827
+
#### noResolve
828
+
829
+
````javascript
830
+
true|false (default)
831
+
````
832
+
833
+
Do not add triple-slash references or module import targets to the list of compiled files.
834
+
835
+
````javascript
836
+
grunt.initConfig({
837
+
ts: {
838
+
options: {
839
+
noResolve:true
840
+
}
841
+
}
842
+
});
843
+
````
844
+
662
845
#### preserveConstEnums
663
846
664
847
````javascript
@@ -679,6 +862,24 @@ grunt.initConfig({
679
862
});
680
863
````
681
864
865
+
#### removeComments
866
+
867
+
````javascript
868
+
true (default)|false
869
+
````
870
+
871
+
Removes comments in the emitted JavaScript if set to `true`. Preserves comments if set to `false`. Note that if `comments` and `removeComments` are both used, the value of `removeComments` will win; regardless, please don't do this as it is just confusing to everyone.
872
+
873
+
````javascript
874
+
grunt.initConfig({
875
+
ts: {
876
+
options: {
877
+
removeComments:false//preserves comments in output.
0 commit comments