Skip to content

Commit e3a20e7

Browse files
martinhillermhegazy
authored andcommitted
Do not redefine __asyncValues if it already exists (microsoft#20460)
The emitted declaration for the __asyncValues variable checked for the global property __asyncIterable instead of its actual declared name __asyncValues. Now the __asyncValues variable is not redefined if it is already present as global variable. This commit fixes issue microsoft#20408.
1 parent 7de8c6b commit e3a20e7

12 files changed

+29
-29
lines changed

src/compiler/transformers/esnext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ namespace ts {
968968
name: "typescript:asyncValues",
969969
scoped: false,
970970
text: `
971-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
971+
var __asyncValues = (this && this.__asyncValues) || function (o) {
972972
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
973973
var m = o[Symbol.asyncIterator];
974974
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();

tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class C3 {
120120
}
121121
}
122122
//// [C4.js]
123-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
123+
var __asyncValues = (this && this.__asyncValues) || function (o) {
124124
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
125125
var m = o[Symbol.asyncIterator];
126126
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
@@ -162,7 +162,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
162162
function reject(value) { resume("throw", value); }
163163
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
164164
};
165-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
165+
var __asyncValues = (this && this.__asyncValues) || function (o) {
166166
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
167167
var m = o[Symbol.asyncIterator];
168168
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();

tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
256256
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
257257
}
258258
};
259-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
259+
var __asyncValues = (this && this.__asyncValues) || function (o) {
260260
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
261261
var m = o[Symbol.asyncIterator];
262262
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
@@ -347,7 +347,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
347347
function reject(value) { resume("throw", value); }
348348
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
349349
};
350-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
350+
var __asyncValues = (this && this.__asyncValues) || function (o) {
351351
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
352352
var m = o[Symbol.asyncIterator];
353353
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();

tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function f3() {
8383
});
8484
}
8585
//// [F4.js]
86-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
86+
var __asyncValues = (this && this.__asyncValues) || function (o) {
8787
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
8888
var m = o[Symbol.asyncIterator];
8989
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
@@ -123,7 +123,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
123123
function reject(value) { resume("throw", value); }
124124
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
125125
};
126-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
126+
var __asyncValues = (this && this.__asyncValues) || function (o) {
127127
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
128128
var m = o[Symbol.asyncIterator];
129129
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();

tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
210210
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
211211
}
212212
};
213-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
213+
var __asyncValues = (this && this.__asyncValues) || function (o) {
214214
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
215215
var m = o[Symbol.asyncIterator];
216216
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
@@ -296,7 +296,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
296296
function reject(value) { resume("throw", value); }
297297
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
298298
};
299-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
299+
var __asyncValues = (this && this.__asyncValues) || function (o) {
300300
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
301301
var m = o[Symbol.asyncIterator];
302302
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();

tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const f3 = function () {
8383
});
8484
};
8585
//// [F4.js]
86-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
86+
var __asyncValues = (this && this.__asyncValues) || function (o) {
8787
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
8888
var m = o[Symbol.asyncIterator];
8989
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
@@ -123,7 +123,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
123123
function reject(value) { resume("throw", value); }
124124
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
125125
};
126-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
126+
var __asyncValues = (this && this.__asyncValues) || function (o) {
127127
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
128128
var m = o[Symbol.asyncIterator];
129129
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();

tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
210210
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
211211
}
212212
};
213-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
213+
var __asyncValues = (this && this.__asyncValues) || function (o) {
214214
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
215215
var m = o[Symbol.asyncIterator];
216216
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
@@ -296,7 +296,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
296296
function reject(value) { resume("throw", value); }
297297
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
298298
};
299-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
299+
var __asyncValues = (this && this.__asyncValues) || function (o) {
300300
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
301301
var m = o[Symbol.asyncIterator];
302302
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();

tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const o3 = {
103103
}
104104
};
105105
//// [O4.js]
106-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
106+
var __asyncValues = (this && this.__asyncValues) || function (o) {
107107
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
108108
var m = o[Symbol.asyncIterator];
109109
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
@@ -145,7 +145,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
145145
function reject(value) { resume("throw", value); }
146146
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
147147
};
148-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
148+
var __asyncValues = (this && this.__asyncValues) || function (o) {
149149
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
150150
var m = o[Symbol.asyncIterator];
151151
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();

tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
230230
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
231231
}
232232
};
233-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
233+
var __asyncValues = (this && this.__asyncValues) || function (o) {
234234
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
235235
var m = o[Symbol.asyncIterator];
236236
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
@@ -318,7 +318,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
318318
function reject(value) { resume("throw", value); }
319319
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
320320
};
321-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
321+
var __asyncValues = (this && this.__asyncValues) || function (o) {
322322
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
323323
var m = o[Symbol.asyncIterator];
324324
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();

tests/baselines/reference/emitter.forAwait.es2015.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
3434
step((generator = generator.apply(thisArg, _arguments || [])).next());
3535
});
3636
};
37-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
37+
var __asyncValues = (this && this.__asyncValues) || function (o) {
3838
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
3939
var m = o[Symbol.asyncIterator];
4040
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
@@ -66,7 +66,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
6666
step((generator = generator.apply(thisArg, _arguments || [])).next());
6767
});
6868
};
69-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
69+
var __asyncValues = (this && this.__asyncValues) || function (o) {
7070
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
7171
var m = o[Symbol.asyncIterator];
7272
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
@@ -90,7 +90,7 @@ function f2() {
9090
});
9191
}
9292
//// [file3.js]
93-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
93+
var __asyncValues = (this && this.__asyncValues) || function (o) {
9494
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
9595
var m = o[Symbol.asyncIterator];
9696
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
@@ -126,7 +126,7 @@ function f3() {
126126
});
127127
}
128128
//// [file4.js]
129-
var __asyncValues = (this && this.__asyncIterator) || function (o) {
129+
var __asyncValues = (this && this.__asyncValues) || function (o) {
130130
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
131131
var m = o[Symbol.asyncIterator];
132132
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();

0 commit comments

Comments
 (0)