Skip to content

Commit e27e744

Browse files
committed
Merge pull request #350 from TypeStrong/implement-ts-1.8
[WIP] Implement Support for TypeScript 1.8
2 parents 649c937 + a03d0b0 commit e27e744

Some content is hidden

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

61 files changed

+1080
-329
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ test/**/*.js
1313
test/**/*.html.ts
1414
!test/expected/htmlExternal/*.ts
1515
test/html/reference.ts
16+
!test/allowJs/allowJsLibrary.js
1617

1718
test/definitelytypedtest/reference.ts
1819
/tscommand*.tmp.txt
@@ -24,6 +25,7 @@ test/definitelytypedtest/reference.ts
2425
!test/expected/**/*.map
2526
!test/commandLineAssertions.js
2627
!test/optionsResolverTests.js
28+
!test/compilerTests.js
2729
.tscache/
2830
!test/tsconfig/*.json
2931
bin/
@@ -32,4 +34,4 @@ obj/
3234
*.suo
3335
.project
3436
.settings/
35-
/.vs
37+
/.vs

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Releases
22

33
## Next
4+
* FEAT: Support TypeScript 1.8+ (coming soon)
5+
6+
## v5.4.0 (2016-03-22)
47
* FIX: amdloader will now work for [`.tsx` extension as well](https://github.com/TypeStrong/grunt-ts/pull/274) [reapplied](https://github.com/TypeStrong/grunt-ts/pull/314)
58
* FIX: tsconfig.json exclude support for files (not just directories). Thanks very much to first-time contributor @errorx666 for the PR! Includes PR #337 which keeps exclude performance fast. (#285, #336)
69
* DOCS: Update to `--moduleResolution` README section to show fluctuating default behaviour - by @thull

CONTRIBUTING.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Contributing to grunt-ts
2+
3+
Thank you for your interest in contributing!
4+
5+
This project is in a mature maintenance phase. This means that the grunt-ts maintainers are focused on the following:
6+
7+
* Compatibility with the latest stable version of TypeScript (native support for new switches, etc.)
8+
* Reliability enhancements such as bug fixes with tests
9+
10+
New features and performance improvements will be considered if they are of broad benefit and well documented/covered with adequate tests. Before you start coding, please open an issue to discuss your idea!
11+
12+
13+
## Steps To Update grunt-ts to a New Version of TypeScript
14+
15+
* Set up a new branch in your fork of the repository.
16+
* Update the dependencies section of `package.json` to the new TypeScript version and run `npm install`.
17+
* Run `grunt release` and see if there are any errors.
18+
* Fix the errors.
19+
* Very commonly there will be "diff" errors. Grunt-ts will generate `kdiff3` commands for all "diff" errors. In cases where the difference is due to how the new version of TypeScript emits the JS code, simply update the expected version to match by merging the changes inside `kdiff3` and choosing `A` for all the changes.
20+
* Once `grunt release` compiles cleanly, check everything in.
21+
* Now, it's necessary to update grunt-ts to support the new TypeScript version's switches. Open `tasks/modules/optionsResolver.ts`. Early in that file is a link to the TypeScript wiki where the compiler options are documented. Compare that list to the switches in `propertiesFromTarget` and `propertiesFromTargetOptions`. Add any new switches to `propertiesFromTargetOptions` unless there is an overwhelmingly strong reason to add it to the target itself.
22+
* Once that is done, add code to accept each of those switches to `ITaskOptions` in `tasks/modules/interfaces.d.ts`. Provide some JSDoc if possible.
23+
* Next, update `tasks/modules/defaults.ts`. First, update the `TypeScriptDefaults` variable to set the new switches to whatever tsc will do - generally `false` for booleans and `null` for everything else (essentially falsy values). Then, if necessary, modify the function `applyGruntTSDefaults` to apply what grunt-ts should do that is different than what `tsc` does by default (this is unlikely for new TypeScript features).
24+
* Then update `tasks/modules/compile.ts` to pass the new switches. Mostly this will be checking for the presence of the option and pushing to the args variable inside `compileAllFiles()`.
25+
* Add a test for the new switches inside the `Gruntfile.js`. A good example is `new_TypeScript_1_8_Features`. The important thing is the `testExecute` property. Add a new function in commandLineAssertions.ts with the same name as the one you specified in testExecute.
26+
* Update tsconfig support - Edit the `sameNameInTSConfigAndGruntTS` variable in the `tsconfig.ts` file with all of the grunt-ts options that are the same as the new option names in the tsconfig.json file (should generally be all of them). Any parameters that don't have the same name in grunt-ts as in tsconfig.json will require more coding in the `applyCompilerOptions` function. Then edit the test/tsconfig_artifact/full_valid_tsconfig.json file to add at least one of the new parameters. Then test for it to be passed in the "config entries come through appropriately" test in `optionsResolverTests.ts`.
27+
* Update VS support - The csproj2ts project needs to be updated. Then update the dependency in the grunt-ts package.json file and run `npm install`. Once that is complete, update the `simpleVSSettingsToGruntTSMappings` array in `tasks/modules/visualStudioOptionsResolver.ts`. Finally, add one or more of the new Visual Studio properties to the `test/vsproj/testproject.csproj` file and also to the "Visual Studio properties come across as expected" test in `optionsResolverTests.ts`.
28+
* Publish a beta.
29+
* Add any additional feature-specific tests that would be useful for the new TypeScript version.
30+
* Add documentation
31+
* Publish the main release (as a feature/point release unless there were major changes).
32+
* If very happy with the release, update the internal compiler with `grunt upgrade`.
33+
34+
35+
36+
## To Start Working On grunt-ts
37+
38+
With npm and grunt-cli installed, run the following from the root of the repository:
39+
40+
```bash
41+
$ npm install
42+
```
43+
### Building the project:
44+
45+
To build all
46+
47+
```bash
48+
$ grunt build
49+
```
50+
### Running the tests:
51+
52+
To test all
53+
54+
```bash
55+
$ grunt test
56+
```
57+
58+
### Before PR
59+
60+
```bash
61+
$ grunt release
62+
```
63+
64+
It runs `build` followed by `test`. This is also the default task. You should run this before sending a PR.
65+
66+
### Development
67+
68+
The easiest/fastest way to work on grunt-ts is to modify `tasksToTest` toward the bottom of the `gruntfile.js`. The `grunt dev` command is set up to compile grunt-ts with your changes and then reload itself; then, your newly-compiled grunt-ts will be used to run whatever tasks are listed in the `tasksToTest` array.
69+
70+
Without using `tasksToTest` while working on grunt-ts, the old grunt-ts remains in memory for successive tasks on the same run. This means you might have to run your grunt commands twice; once to compile grunt-ts and once to see how the new grunt-ts works with your code.
71+
72+
### Quickstart for debugging Grunt plugins with Node Inspector
73+
74+
Install [Node Inspector](https://github.com/node-inspector/node-inspector) via npm:
75+
76+
`npm install -g node-inspector`
77+
78+
Example command-line to debug a grunt-ts task on Windows:
79+
80+
`node-debug --debug-brk %appdata%\npm\node_modules\grunt-cli\bin\grunt ts:files_testFilesUsedWithDestAsAJSFile`
81+
82+
Example command-line to debug a particular nodeunit test on Windows:
83+
84+
`node-debug --debug-brk node_modules\grunt-contrib-nodeunit\node_modules\nodeunit\bin\nodeunit test\optionsResolverTests.js -t "out with spaces gets escaped with double-quotes"`
85+
86+
87+
Set breakpoints in the Chrome dev tools, or use `debugger;` where needed.
88+
89+
### Additional commands
90+
Update the current `grunt-ts` to be the last known good version (dogfood). Commit message should be `Update LKG`.
91+
92+
```bash
93+
$ grunt upgrade
94+
```
95+
96+
### Publishing Checklist
97+
98+
* Run `grunt release` and ensure it comes back clean (should finish but with warnings).
99+
* Update the version in package.json.
100+
* Update CHANGELOG.md and README.md (top section referencing latest version number).
101+
* Commit to master.
102+
* Publish to npm.
103+
* Push version tag to GitHub.

Gruntfile.js

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ module.exports = function (grunt) {
2222
'tscommand-*.txt',
2323
'!test/commandLineAssertions.js',
2424
'!test/optionsResolverTests.js',
25-
'test/**/*.orig'
25+
'!test/compilerTests.js',
26+
'test/**/*.orig',
27+
'!test/allowJs/allowJsLibrary.js'
2628
],
2729
testPost: [
2830
'src/a.js',
@@ -63,12 +65,15 @@ module.exports = function (grunt) {
6365
src: ['tasks/**/*.ts']
6466
},
6567
test: {
66-
src: ['test/test.ts', 'test/commandLineAssertions.ts', 'test/optionsResolverTests.ts']
68+
src: ['test/test.ts',
69+
'test/commandLineAssertions.ts',
70+
'test/optionsResolverTests.ts',
71+
'test/compilerTests.ts']
6772
}
6873
},
6974
nodeunit: {
7075
slow: ['test/test.js'],
71-
fast: ['test/optionsResolverTests.js']
76+
fast: ['test/optionsResolverTests.js', 'test/compilerTests.js']
7277
},
7378
watch: {
7479
dev: {
@@ -669,7 +674,34 @@ module.exports = function (grunt) {
669674
},
670675
html: 'test/htmlExternal/**/*.html',
671676
src: 'test/htmlExternal/**/*.ts'
672-
677+
},
678+
new_TypeScript_1_8_Features: {
679+
test: true,
680+
testExecute: commandLineAssertions.new_TypeScript_1_8_Features,
681+
src: 'test/simple/ts/**/*.ts',
682+
options: {
683+
reactNamespace: 'myReact',
684+
skipDefaultLibCheck: true,
685+
pretty: true,
686+
allowUnusedLabels: true,
687+
noImplicitReturns: true,
688+
noFallthroughCasesInSwitch: true,
689+
allowUnreachableCode: true,
690+
forceConsistentCasingInFileNames: true,
691+
allowJs: true,
692+
noImplicitUseStrict: true
693+
}
694+
},
695+
allowJs_CompileWorks: {
696+
test: true,
697+
src: ['test/allowJs/allowJsConsumer.ts',
698+
'test/allowJs/allowJsLibrary.js'],
699+
out: 'test/allowJs/result.js',
700+
options: {
701+
allowJs: true,
702+
noEmitOnError: true,
703+
module: 'system'
704+
}
673705
},
674706
decoratorMetadataPassed: {
675707
test: true,
@@ -1172,8 +1204,17 @@ module.exports = function (grunt) {
11721204

11731205
grunt.registerTask('stageFiles','Ensures that certain files that are cleaned will be present for the tests.',
11741206
function() {
1207+
var done = this.async();
11751208
try {
1176-
utils.copyFileSync('test/tsconfig_artifact/tsconfig-grunt-ts.json','test/tsconfig/tsconfig-grunt-ts.json');
1209+
utils.copyFile('test/tsconfig_artifact/tsconfig-grunt-ts.json','test/tsconfig/tsconfig-grunt-ts.json',
1210+
function (err) {
1211+
if (err) {
1212+
grunt.log.writeln(err);
1213+
done(false);
1214+
}
1215+
done();
1216+
}
1217+
);
11771218
} catch (ex) {
11781219
console.log(ex);
11791220
return false;

README.md

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,75 +1536,6 @@ Note that it is not currently possible to force TypeScript to emit all JavaScrip
15361536

15371537
<a href="https://youtu.be/0-6vT7xgE4Y" target="_blank" alt="AngularJS + TypeScript : Workflow"><img src="https://img.youtube.com/vi/0-6vT7xgE4Y/0.jpg" /></a>
15381538

1539-
## Contributing
1540-
1541-
With npm and grunt-cli installed, run the following from the root of the repository:
1542-
1543-
```bash
1544-
$ npm install
1545-
```
1546-
### Building the project:
1547-
1548-
To build all
1549-
1550-
```bash
1551-
$ grunt build
1552-
```
1553-
### Running the tests:
1554-
1555-
To test all
1556-
1557-
```bash
1558-
$ grunt test
1559-
```
1560-
1561-
### Before PR
1562-
1563-
```bash
1564-
$ grunt release
1565-
```
1566-
1567-
It runs `build` followed by `test`. This is also the default task. You should run this before sending a PR.
1568-
1569-
### Development
1570-
1571-
The easiest/fastest way to work on grunt-ts is to modify `tasksToTest` toward the bottom of the `gruntfile.js`. The `grunt dev` command is set up to compile grunt-ts with your changes and then reload itself; then, your newly-compiled grunt-ts will be used to run whatever tasks are listed in the `tasksToTest` array.
1572-
1573-
Without using `tasksToTest` while working on grunt-ts, the old grunt-ts remains in memory for successive tasks on the same run. This means you might have to run your grunt commands twice; once to compile grunt-ts and once to see how the new grunt-ts works with your code.
1574-
1575-
### Quickstart for debugging Grunt plugins with Node Inspector
1576-
1577-
Install [Node Inspector](https://github.com/node-inspector/node-inspector) via npm:
1578-
1579-
`npm install -g node-inspector`
1580-
1581-
Example command-line to debug a grunt-ts task on Windows:
1582-
1583-
`node-debug --debug-brk %appdata%\npm\node_modules\grunt-cli\bin\grunt ts:files_testFilesUsedWithDestAsAJSFile`
1584-
1585-
Example command-line to debug a particular nodeunit test on Windows:
1586-
1587-
`node-debug --debug-brk node_modules\grunt-contrib-nodeunit\node_modules\nodeunit\bin\nodeunit test\optionsResolverTests.js -t "out with spaces gets escaped with double-quotes"`
1588-
1589-
1590-
Set breakpoints in the Chrome dev tools, or use `debugger;` where needed.
1591-
1592-
### Additional commands
1593-
Update the current `grunt-ts` to be the last known good version (dogfood). Commit message should be `Update LKG`.
1594-
1595-
```bash
1596-
$ grunt upgrade
1597-
```
1598-
1599-
### Publishing Checklist
1600-
1601-
* Run `grunt release` and ensure it comes back clean (should finish but with warnings).
1602-
* Update the version in package.json.
1603-
* Update CHANGELOG.md and README.md (top section referencing latest version number).
1604-
* Commit to master.
1605-
* Publish to npm.
1606-
* Push version tag to GitHub.
1607-
16081539
## License
16091540

16101541
Licensed under the MIT License.

0 commit comments

Comments
 (0)