Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit e999593

Browse files
JiaLiPassionmhevery
authored andcommitted
feat(compile): fix #892, upgrade to typescript 2.3.4, support for...of when build zone-node (#897)
* feat(compile): fix #892, upgrade to typescript 2.3.4(same with angular), add downlevelIteration options when build zone-node * local test should also use downlevelIteration option
1 parent aec4bd4 commit e999593

File tree

6 files changed

+94
-5
lines changed

6 files changed

+94
-5
lines changed

gulpfile.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ function generateScript(inFile, outFile, minify, callback) {
2323
.pipe(rollup({
2424
entry: inFile,
2525
format: 'umd',
26+
onwarn: function (warning) {
27+
// https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
28+
if (warning.code === 'THIS_IS_UNDEFINED') {
29+
return;
30+
}
31+
console.error(warning.message);
32+
},
2633
banner: '/**\n'
2734
+ '* @license\n'
2835
+ '* Copyright Google Inc. All Rights Reserved.\n'
@@ -71,16 +78,24 @@ gulp.task('compile', function(cb) {
7178
tsc('tsconfig.json', cb);
7279
});
7380

81+
gulp.task('compile-node', function(cb) {
82+
tsc('tsconfig-node.json', cb);
83+
});
84+
7485
gulp.task('compile-esm', function(cb) {
7586
tsc('tsconfig-esm.json', cb);
7687
});
7788

89+
gulp.task('compile-esm-node', function(cb) {
90+
tsc('tsconfig-esm-node.json', cb);
91+
});
92+
7893
gulp.task('build/zone.js.d.ts', ['compile-esm'], function() {
7994
return gulp.src('./build-esm/lib/zone.d.ts').pipe(rename('zone.js.d.ts')).pipe(gulp.dest('./dist'));
8095
});
8196

8297
// Zone for Node.js environment.
83-
gulp.task('build/zone-node.js', ['compile-esm'], function(cb) {
98+
gulp.task('build/zone-node.js', ['compile-esm-node'], function(cb) {
8499
return generateScript('./lib/node/rollup-main.ts', 'zone-node.js', false, cb);
85100
});
86101

@@ -90,7 +105,7 @@ gulp.task('build/zone.js', ['compile-esm'], function(cb) {
90105
});
91106

92107
// Zone for electron/nw environment.
93-
gulp.task('build/zone-mix.js', ['compile-esm'], function(cb) {
108+
gulp.task('build/zone-mix.js', ['compile-esm-node'], function(cb) {
94109
return generateScript('./lib/mix/rollup-mix.ts', 'zone-mix.js', false, cb);
95110
});
96111

@@ -257,7 +272,7 @@ gulp.task('build', [
257272
'build/closure.js'
258273
]);
259274

260-
gulp.task('test/node', ['compile'], function(cb) {
275+
gulp.task('test/node', ['compile-node'], function(cb) {
261276
var JasmineRunner = require('jasmine');
262277
var jrunner = new JasmineRunner();
263278

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"ts-loader": "^0.6.0",
9494
"tslint": "^4.1.1",
9595
"tslint-eslint-rules": "^3.1.0",
96-
"typescript": "2.2.1",
96+
"typescript": "2.3.4",
9797
"vrsource-tslint-rules": "^4.0.0",
9898
"webdriver-manager": "^12.0.6",
9999
"webdriverio": "^4.8.0",

test/common/Promise.spec.ts

+24
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import {isNode} from '../../lib/common/utils';
910
import {ifEnvSupports} from '../test-util';
11+
1012
declare const global: any;
1113

1214
class MicroTaskQueueZoneSpec implements ZoneSpec {
@@ -365,6 +367,28 @@ describe(
365367
expect(value).toEqual(['resolution', 'v1']);
366368
});
367369
});
370+
371+
it('should resolve generators', ifEnvSupports(
372+
() => {
373+
return isNode;
374+
},
375+
() => {
376+
const generators: any = function*() {
377+
yield Promise.resolve(1);
378+
yield Promise.resolve(2);
379+
return;
380+
};
381+
queueZone.run(() => {
382+
let value = null;
383+
Promise.all(generators()).then(val => {
384+
value = val;
385+
});
386+
// expect(Zone.current.get('queue').length).toEqual(2);
387+
flushMicrotasks();
388+
expect(value).toEqual([1, 2]);
389+
});
390+
391+
}));
368392
});
369393
});
370394

tsconfig-esm-node.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"module": "es2015",
4+
"target": "es5",
5+
"noImplicitAny": true,
6+
"noImplicitReturns": false,
7+
"noImplicitThis": false,
8+
"outDir": "build-esm",
9+
"inlineSourceMap": false,
10+
"inlineSources": false,
11+
"declaration": true,
12+
"noEmitOnError": false,
13+
"stripInternal": true,
14+
"sourceMap": true,
15+
"downlevelIteration": true,
16+
"moduleResolution": "node",
17+
"lib": ["es5", "dom", "es2015.promise"]
18+
},
19+
"exclude": [
20+
"node_modules",
21+
"build",
22+
"build-esm",
23+
"dist",
24+
"lib/closure"
25+
]
26+
}

tsconfig-esm.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
"dist",
2323
"lib/closure"
2424
]
25-
}
25+
}

tsconfig-node.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es5",
5+
"noImplicitAny": true,
6+
"noImplicitReturns": false,
7+
"noImplicitThis": false,
8+
"outDir": "build",
9+
"inlineSourceMap": true,
10+
"inlineSources": true,
11+
"declaration": false,
12+
"downlevelIteration": true,
13+
"noEmitOnError": false,
14+
"stripInternal": false,
15+
"lib": ["es5", "dom", "es2015.promise"]
16+
},
17+
"exclude": [
18+
"node_modules",
19+
"build",
20+
"build-esm",
21+
"dist",
22+
"lib/closure"
23+
]
24+
}

0 commit comments

Comments
 (0)